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 Cases

test write lines to file - Run Test

import tempfile

def test_write_lines_to_file():
    fp = tempfile.NamedTemporaryFile(mode="w")
    write_lines((, ['my', 'name', 'is', 'john'])

    with open( as fp:
        assert len(fp.readlines()) == 4
        assert fp.readlines()[2] == 'is\n'
def write_lines(filepath, list_of_strings): pass