This is part of my homework and the reason why I found posted this was because I was confused about what I'm doing wrong.
school = [['Abby Li'],
['Ella Wang', 'Danielle Han','Katherine Zhang', 'Morgan Liu'],
['Josh Li']
]
def searchStudent(school1, lastname1):
firstname = "Not"
lastname = "Found"
for grade in school1:
for student in grade:
name = student.split();
if name[1] == lastname1:
firstname = name[0]
lastname = name[1]
return firstname, lastname
while (True):
search = input("Please enter last name to search:")
if (search == "exit"):
break
foundFirst, foundLast = searchStudent(school, search)
print("found student: ", foundFirst, foundLast)
print("")
So this is my code, but whenever I enter "Li" as the last name, only Josh shows up and Abby doesn't. Can someone help me fix it? Thank you so much!
Also, here's the link for it if it doesn't show up above: code