Issue
Hi guys I'm new in programming and Stackoverflow and English is my second language if I have some mistakes , forgive me. I'm writing code for my teacher about a list which you get information name , ID number , and name. My problem is that at the end of loop I don't know how to make a list of All information . that's my code :
loopnumber = int(input("please enter your number of people"))
for i in range (loopnumber) :
IDnumber = input("please enter your ID number.")
while len(IDnumber) != 10 :
IDnumber = input("please try again.")
name = input("please enter your name.")
age = int(input("please enter your age."))
while age <= 0 :
age = int(input(" please try Again."))
listpeople = [IDnumber, name, age ]
Thanks a lot.
Solution
Start with a list then keep append
ing your information as a list itself.
# start with the empty list
listpeople = []
loopnumber = int(input("please enter your number of people"))
for i in range (loopnumber) :
IDnumber = input("please enter your ID number.")
while len(IDnumber) != 10 :
IDnumber = input("please try again.")
name = input("please enter your name.")
age = int(input("please enter your age."))
while age <= 0 :
age = int(input(" please try Again."))
# put all the data you have in a list
individual_details = [IDnumber, name, age]
# append the personal_details list to the parent list aka listpeople
listpeople.append(individual_details)
Answered By - anyfactor
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.