+ 2
I am not able to detect the error, logic is correct.Help me out with this
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")
3 ответов
+ 7
Kashish Khan ,
here some hints:
> the output 'Not found' is currently printed repeatedly depending on the position of the word in the contacts list.
> this output should be given only once from outside of the for loop
> maybe you need a helpers variable that holds the state if the input word is found inside the loop or not
+ 3
The logic is not whole correct. Try to solve it yourself. This is better for learning of solution skills.
+ 1
I don't think the logic is correct try reviewing your code