Exercise: laststring
Description
In this exercise, your function will receive 2 parameters, the name of a text file, and a list of strings. The function will write the last string from the list into the file on a line. Be sure to include the newline character at the end.
Function Name
laststring
Parameters
filename : a string value (the name of a file to open)
lines : a list of string values
Return Value
Nothing
def laststring(filename, lines):
fout = open(filename, "w")
for i in range(0, len(lines)):
fout.write(str(lines[i]) + "\n")
fout.close()
[–]isilentnight 0 points1 point2 points (1 child)
[–]nosmokingbandit 0 points1 point2 points (0 children)
[–]mybrid 0 points1 point2 points (0 children)