Answered step by step
Verified Expert Solution
Question
1 Approved Answer
) 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 tooStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started