179k views
0 votes
The function takes two string parameters; the first is the name of a file and the second is text. Complete the function to append the string text onto the end of the file named filename. You'll want to open the file for appending and then you can use a single write function call to complete the write. Be sure that you close the file, either with an explicit close function call or by using a with statement.

User Atavio
by
5.3k points

1 Answer

1 vote

Answer:

The code for the function is given below in Python language

Step-by-step explanation:

def append_string_to_file(filename, text):// function takes the filename // and text to append

f = open(filename, 'a')

f.write(text) //function part that writes the text

f.close() //closing the file using the explicit close function

User Pixelpax
by
4.9k points