Computer Science, asked by nith59, 3 months ago

search element 20 30 40 60 70 80 90 100 element in an array find the element 20​

Answers

Answered by jai696
3

\huge\red{\mid{\fbox{\tt{Using\: Python\: 3}}\mid}}

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")

\large\mathsf\color{lightgreen}useful?\: \color{white}\longrightarrow\: \color{orange}brainliest!

Similar questions