K=[30,15,25,50,40,35,44,49,55,54]
Search = int(input("enter the value you want to search"))
Index=0
Found=False
while Index<=9 and Found==False:
if K[Index]==Search:
print("Match found")
Found=True
else:
print("Match not found")
Index=Index+1
the result for this code when the value used are 15 comes out as;
Match not found
Match found
however, when i enter the value to be searched as 30 the results come out correctly as;
Match found
however when i enter 54 as the value to be searched the results come out as;
Match not found
Match not found
Match not found
Match not found
Match not found
Match not found
Match not found
Match not found
Match not found
Match found
can someone help me figure out why the results differ in this way for each value tested, what's wrong with my code and also what do I do to fix it also, I'm a beginner and have no idea what I'm doing yet so I might have made a dumb mistake and also I'm aware there are easier ways of searching up values in a list but I need to learn this specific method so please help me with this one