Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

) 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions