Ask Question
22 August, 05:37

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.

+1
Answers (1)
  1. 22 August, 05:56
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers