Menu
support@nursinghomework.org
+1 714-215-3097

(Solved) : Write Function Called Read Words Filename Accepts Single String Represents File Name Param Q35625341

python question. pls use simple way
Write a function called read words filename) that accepts a single string that represents a file name as a parameter The fileWrite a function called read words filename) that accepts a single string that represents a file name as a parameter The file should be a plain text file. Your function should return a list of all the words that appear in the file, in the same order they occur in that file. The list may include duplicate words (i.e. if the file contains the same word multiple times then it will appear in the list multiple times) In this exercise, a word is considered to be any sequence of characters separated with whitespace For example: Yl Test Result print (read words(‘t [‘A, ‘simple’, ‘file , with’, ‘onl esti.txt’)) y, one, ‘line’] print (read words(‘t[‘This, file est2.txt’)) has’, ‘five’, ‘line Answer (penalty regime 0, 10, 20, 30, 40, 50%) 1 .ldef read_words(filename): 2a list [1 3file in open(filename, ) contents file in.read) sfile_in.close() 7 9 6for words in contents.split): a_list- [words] return a_list 10 Precheck Check Syntax Error(s) TabError: inconsEstent use of tabs and spaces in Indent Show transcribed image text Write a function called read words filename) that accepts a single string that represents a file name as a parameter The file should be a plain text file. Your function should return a list of all the words that appear in the file, in the same order they occur in that file. The list may include duplicate words (i.e. if the file contains the same word multiple times then it will appear in the list multiple times) In this exercise, a word is considered to be any sequence of characters separated with whitespace For example: Yl Test Result print (read words(‘t [‘A, ‘simple’, ‘file , with’, ‘onl esti.txt’)) y, one, ‘line’] print (read words(‘t[‘This, file est2.txt’)) has’, ‘five’, ‘line Answer (penalty regime 0, 10, 20, 30, 40, 50%) 1 .ldef read_words(filename): 2a list [1 3file in open(filename, ) contents file in.read) sfile_in.close() 7 9 6for words in contents.split): a_list- [words] return a_list 10 Precheck Check Syntax Error(s) TabError: inconsEstent use of tabs and spaces in Indent

Leave a Reply

Your email address will not be published. Required fields are marked *