0

Issue with the tuple coding exercise?

Tuple coding exercise issue even with the solution that solo learn provides. 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 elif x not in contacts: print("Not Found")

23rd Aug 2023, 7:27 PM
Cristian Chavez
Cristian Chavez - avatar
2 Respostas
+ 8
# Try this code. # Hint: the else block will not be executed if the loop is stopped by a break statement. for x in contacts: if name in x: print(x) break else: print("Not Found")
23rd Aug 2023, 9:05 PM
JaScript
JaScript - avatar
+ 1
It should be elif name not in x Basically just "else" statement would do the same
24th Aug 2023, 4:08 PM
Toni Isotalo
Toni Isotalo - avatar