+ 4

What am I doing wrong ?

Test 1,2,3 and 4 work perfectly ,5 not

4th Aug 2022, 6:39 AM
Andreea Sandor
Andreea Sandor - avatar
4 Respostas
+ 6
Your code is fine, the only issue is the string "Not Found" it should be "Not found" lower case f in "found".
4th Aug 2022, 7:13 AM
Bahhaⵣ
Bahhaⵣ - avatar
+ 1
contacts = [ ('James', 42), ('Amy', 24), ('John', 31), ('Amanda', 63), ('Bob', 18) ] name = input() for x in contacts: if name in x: print(str(x[0]) +" is " + str(x[1])) break else: print("Not Found")
4th Aug 2022, 7:05 AM
Andreea Sandor
Andreea Sandor - avatar
+ 1
It worked ,thank you so much!
4th Aug 2022, 7:14 AM
Andreea Sandor
Andreea Sandor - avatar
0
You are given a list of contacts, where each contact is represented by a tuple, with the name and age of the contact. Complete the program to get a string as input, search for the name in the list of contacts and output the age of the contact in the format presented below: Sample Input John Sample Output John is 31
4th Aug 2022, 7:06 AM
Andreea Sandor
Andreea Sandor - avatar