Question: ) The second way to read text from a file is shown in the middle of p. 113. On line 7 of that listing we

) The second way to read text from a file is shown in the middle of p. 113. On line 7 of
that listing we see: wordList = content.split()
What does the .split() method do, and what is stored in wordList as a result?
def numWords (filename): 'returns the number of words in file filename' infile = open(filename, 'r') content = infile.read() # read the file into a string infile.close() wordList = content.split() print (wordList) return len(wordList) # split file into list of words # print list of words too
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
