Ask Question
12 August, 08:57

Define a Python function named file_listers with two parameters. The first parameter will be a string specifying the name of the file to write to. The second parameter will be a list of str. Your function should open the file in a manner that erases its contents. For each entry in the second parameter, write it to the file and then a newline. Your function does not need to return anything. Example:list_2_file ("empty. txt", []) creates a file named empty. txt but that file will be empty. list_2_file ("simple. txt", ["Write", "me"]) creates a file named simple. txt which contains two lines of text. The first line has the text Write and the second line says me.

+2
Answers (1)
  1. 12 August, 10:43
    0
    Check the explanation

    Explanation:

    we can now create a file named simple. txt which contains two lines of text

    below is the solution to the question:

    def file_listers (filename, strlist):

    name=raw_input (filename)

    file = open (file, 'w')

    with file as ≠:

    for i in range (0, len (strlist)):

    f. write (strlist[i]+"/n")

    file. close ();
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Define a Python function named file_listers with two parameters. The first parameter will be a string specifying the name of the file to ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers