Answer to Question #99394 in Python for Tobe

Question #99394
Count the number of lines in the file, then generate a random knock-knock joke from the file.

Sample Run

Knock-Knock
Who's there?
Rabbit

Rabbit
who?
Rabbit up carefully it's a present!
1
Expert's answer
2019-11-27T07:13:24-0500
file = open("file.txt")
lines = file.readlines()
print("number of lines: " + str(len(lines)))
for i in lines:
    print(i)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS