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")
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")
+ 1
It should be
elif name not in x
Basically just "else" statement would do the same