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
>>>
>>>
That program reads number of lines present in file "poemBTH.txt".
ReplyDeleteYes.
DeleteWhere is output
ReplyDeleteIt is depending on Poem.txt file
DeleteWhat is the output
ReplyDeleteOk, I have uploaded Example : )
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )