Q. Consider the file poem.txt and predict the output of following code fragment. What exactly is following code fragment doing?

f = open ("poemBTH.txt", "r")

nl = 0

for line in f:

    nl += 1

print (nl)

Answer :- This program reads the number of lines present in the file "poem.txt".

For Example if poem .txt file content this :-

This is
Path Walla
Website 
Thank you : )

Our Output :-

4
>>>


6 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post