Q. Write a program to search the names and addresses of persons having age more than 30 in the data list of persons.
Answer :-
Let us consider the content of the file to be like this -
Name, address, age
f = open("Pathwalla.txt",'r') data = f.readlines() for i in data : age = i.split(",") if int(age[ 2 ]) >= 30 : print(age[0])
Let us consider the content of the file to be like this -
Path ,India ,44
Walla ,USA ,12
Portal ,UK ,5
Express ,UAE ,30
Walla ,USA ,12
Portal ,UK ,5
Express ,UAE ,30
Output :-
Path
Express
>>>
Express
>>>
output please
ReplyDeleteOk, : )
DeleteSplit kyun kiya
ReplyDeleteBecause after spliting we will get list like ["Path" , "india" , "44"], So from list we can directly get age.
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )