search element 20 30 40 60 70 80 90 100 element in an array find the element 20
Answers
Answered by
3
def search(arr, item):
for i in range(len(arr)):
if arr[i] == item: return i
return -1
nums = [20, 30, 40, 60, 70, 80, 90, 100]
idx = search(nums, 20)
print(f"item found at idx {idx}") if idx > -1 else print("item not found")
Similar questions