+ 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")

24th Oct 2022, 9:18 AM
Kashish Khan
3 Respostas
+ 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
24th Oct 2022, 4:01 PM
Lothar
Lothar - avatar
+ 3
The logic is not whole correct. Try to solve it yourself. This is better for learning of solution skills.
24th Oct 2022, 9:31 AM
JaScript
JaScript - avatar
+ 1
I don't think the logic is correct try reviewing your code
25th Oct 2022, 12:48 PM
Abdulbasit Y Morai
Abdulbasit Y Morai - avatar