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
1 year 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
1 year agoShadow Era | Shadow Warrior Opening
4 -
13:37
Exploring With Nug
12 hours ago $5.41 earnedSUV Found Underwater Searching For Missing Man Jerry Wilkins!
55K4 -
2:58:21
xBuRnTx
7 hours ago1st Warzone Stream Online
37.6K2 -
6:10:21
JdaDelete
1 day ago $3.66 earnedDino Crisis - Sega Saturday
66K4 -
23:22
MYLUNCHBREAK CHANNEL PAGE
1 day agoUnder The Necropolis - Pt 5
67.4K29 -
2:26:11
Jewels Jones Live ®
2 days agoWINNING BIGLY | A Political Rendezvous - Ep. 108
132K44 -
2:04:49
Bare Knuckle Fighting Championship
4 days agoBKFC FIGHT NIGHT MOHEGAN SUN FREE FIGHTS
63.1K7 -
25:09
BlackDiamondGunsandGear
10 hours agoYou NEED to be Training For Whats to Come
43.9K11 -
20:03
Sideserf Cake Studio
16 hours ago $1.64 earnedA HUNGRY HUNGRY HIPPOS CAKE THAT ACTUALLY WORKS?
42.4K13 -
23:51
marcushouse
16 hours ago $1.38 earnedStarship’s Next Move Is Coming Sooner Than You Think!
30K6