This is a part of our assignments for Computer Programming in high school. These are the instructions. https://prospect.schoolloop.com/file/1407107943880/1376109333800/2888156401519472863.pdf
def c7():
myList = [7, 10, 94, 2, 54, 2, 19, 4, 11]
print (myList)
valueToSearch = int(input("Enter the value to search for: "))
for n in range(0, len(myList)):
if valueToSearch == myList[n]:
print (myList[n], "is in index", n)
elif (n == len(myList)-1) and (valueToSearch != myList[n]):
print ("No matches")
For example:
>>> c7()
[7, 10, 94, 2, 54, 2, 19, 4, 11]
Enter the value to search for: 1
No matches
>>> c7()
[7, 10, 94, 2, 54, 2, 19, 4, 11]
Enter the value to search for: 7
(7, 'is in index', 0)
No matches
The last line "No matches" is unexpected when the input is 7.