Q. Write a program to display all the records in a file along with line/record number.
Answer =
Let us consider content of file be like --
Path, walla, cp
Computer, portal, express
f = open("pathwalla.txt",'r') data = f.readlines() for i in range (len(data)) : line = data[ i ].split(",") print("Line number =",i+1) for j in range (len(line)): print("Record number = ",j+1,end=" , ") print(line[ j ]) f.close()
Output :-
Line number = 1
Record number = 1 , Path
Record number = 2 , walla
Record number = 3 , cp
Line number = 2
Record number = 1 ,
Line number = 3
Record number = 1 , Computer
Record number = 2 , portal
Record number = 3 , express
>>>
what is it's output?
ReplyDeleteOk.
DeleteTrace Table Should Be Appy
ReplyDelete?????
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )