I´m trying to build an Address Book and the propose to create a Search function is so that it can present the Phone Number and Email of that "Name" (Person).
The person was added before so it looks like this:
lst = [['Robert', '12', 'robert@live.com'], ['Steve', '1', 'steve@limework.com']]
and I want to locate Robert (per example) and print his number (12) and email (robert@live.com).
At the moment my Code looks like this:
def searach(lst):
name=str(input("Name:"))
for i in range(len(lst)):
for i in range(len(lst)):
if name == lst[i]:
m=i
print(lst[m][1]) and print(lst[m][2])
break
else:
print("Name doesn´t exist!")
When I do print(len(lst))
it return a value of 0 so it can´t iterate over the list in order to provide me the phone and email I need but when I do print(lst[0][1])
and print(lst[0][2])
it returns the correct Phone and Email of the 1st person on the list in this case Robert.
My post is different from the one suggested since I have 3 variables.