3.6k views
4 votes
Write a Python code to ask a user to enter students' information including name,

last name and student ID number. The program should continue prompting the
user to enter information until the user enters zero. Then the program enters
search mode. In this mode, the user can enter a student ID number to retrieve
the corresponding student's information. If the user enters zero, the program
stops. (Hint: consider using list of lists)​

1 Answer

3 votes

database = ([[]])

while True:

first_name = input("Enter the student's first name: ")

if first_name == "0":

while True:

search = input("Enter a student ID number to find a specific student: ")

if [] in database:

database.pop(0)

if search == "0":

exit()

k = 0

for w in database:

for i in database:

if i[2] == search:

print("ID number: {} yields student: {} {}".format(i[2], i[0], i[1]))

search = 0

last_name = input("Enter the student's last name: ")

id_number = input("Enter the student's ID number: ")

database.append([first_name, last_name, id_number])

I hope this helps!

User Blawzoo
by
4.6k points