Solutions will be available when this assignment is resolved, or after a few failing attempts.
Write List of Strings into File
Write a function that receives a path to a text file as first parameter and
a list of string as second one. The function should write each string in a new
line of the text file. If 5 strings are given in the list, the resulting file
should have 5 lines.
write_lines('test-file.txt', ['hello', 'world'])
test write lines to file - Run Test
import tempfile def test_write_lines_to_file(): fp = tempfile.NamedTemporaryFile(mode="w") write_lines((fp.name), ['my', 'name', 'is', 'john']) with open(fp.name) as fp: assert len(fp.readlines()) == 4 fp.seek(0) assert fp.readlines() == 'is\n'