Question: USING THE PYTHON PROGRAMMING LANGUAGE Suppose that I have a list defined as follows: myList = [1, 8, 3, 7, 2] I try to write
USING THE PYTHON PROGRAMMING LANGUAGE
Suppose that I have a list defined as follows:
myList = [1, 8, 3, 7, 2]
I try to write code to search the list as follows:
searchEntry = int(input("Search for: "))
found = False
for elt in myList:
if searchEntry == elt:
found = True
print("Found")
break
else:
found = False
print("Not Found")
To my chagrin, when the user enters 3 for searchEntry, this does NOT work the way that I intend it to. What DOES print out? How could I fix this code?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
