mercredi 23 décembre 2020

Python Code Has Errors That I Don't Know How To Solve (Beginner)

I'm a beginner to Python, and right now doing linear searches. This is a code to search the item the user has entered from an index stored in a computer. However I have 2 syntax errors that I can't work around. Any help would be useful.

Syntax 1 Syntax 2

upperbound = 7
lowerbound = 0

arr = [0 for i in range(7)]

print("Please enter item to be found: ")
item = input("Please Enter Item To Be Found: ")

Found = False
index = lowerbound

while (found = True) or (index > upperbound):
    if item = arr[index]
    found = True
    break
    index = index + 1

if found:
    print("Item Found")
else:
    print("Item Not Found")

Aucun commentaire:

Enregistrer un commentaire