(MUST BE IN PYTHON 2.7) storm.txt file content: It sounded as if the streets wer
ID: 3830148 • Letter: #
Question
(MUST BE IN PYTHON 2.7)
storm.txt file content:
It sounded as if the streets were running,
And then the streets stood still.
Eclipse was all we could see at the window,
And awe was all we could feel.
By and by the boldest stole out of his covert,
To see if time was there.
Nature was in her beryl apron,
Mixing fresher air.
Explanation / Answer
thefile = open('storm.txt', 'w')
with open("storm.txt", "r") as ins:
word_count = 0
word_count1= []
arry = []
for line in ins:
temp = line.split(" ")
word_count = word_count + len(temp)
word_count1.append(len(temp))
if not line.strip():
continue
thefile.write("%s"%line)
print(word_count)
word_count1.sort()
print(word_count1[-1])
print(word_count1[0])
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.