Premium Only Content
This video is only available to Rumble Premium subscribers. Subscribe to
enjoy exclusive content and ad-free viewing.

Opening and Reading a File |Section 5| Celestial Warrior
2 years ago
1
Please download the text file from the attachment.
Then write some code that reads the content of the file andgenerates the following output in the command line:
pear
apple
orange
mandarin
watermelon
pomegranate
file = open("fruits.txt", "r")
content = file.read()
file.close()
print(content)
Please modify thecode of the previous exerciseso that instead of printing out thelines in the terminal, it prints out the length of each line.
Expected output:
4
5
6
8
10
11
file = open("fruits.txt", "r")
content = file.readlines()
file.close()
for i in content:
print(len(i.strip()))
Loading comments...
-
17:53
foyo Games
2 years agoShadow Era | Shadow Warrior Opening
4 -
28:39
Afshin Rattansi's Going Underground
1 day agoDonald Trump’s Gaza Peace Plan: A Pivotal Moment or Farce? (Palestinian Deputy Foreign Minister)
7871 -
LIVE
SavageJayGatsby
3 hours ago🔥 Spicy Saturday – Let's Play: Prison Life 2🔥
118 watching -
LIVE
cosmicvandenim
9 hours agoCOSMIC VAN DENIM | WARZONE HORROR
106 watching -
29:09
Stephen Gardner
7 hours ago🚨Trump DECLARES WAR on TERRORIST LEFT!
8.56K34 -
LIVE
NellieBean
2 hours ago🔴 Lost Girl looks for Lost Village
65 watching -
30:07
JohnXSantos
1 day agoWhy Clothing Brands NEVER Fail- Master Class
8 -
LIVE
Spartan
1 hour agoOMiT Spartan | God of War Ragnarok, College Halo match @ 9:30 EST, then ranked or more GoW:R
7 watching -
LIVE
John_Goetz
55 minutes agoJohn Gets Gaming - Ghost of Yotei
14 watching -
LIVE
AgnoLand
1 hour ago[LIVE] Battlefield 6 | Full Focus, Cinematic Moments, Zero Fear 😎
20 watching