Algorithm to find numbers larger than 10 in a list does not return correct answers

I wanted to write an algorithm to see what number is more than 10 in an array and print it out, but rather than showing 27 it shows 4.

What did I do wrong?

My code is looking like this:

def findLargestNumberinArray(arr):
    for i in range(len(arr)):
        if (arr[i] > 10):
            return i
    return -1
    
arr = [1, 9, 3, 27, 0.5, 4, 16, 2]
result = findLargestNumberinArray(arr)
if result != -1:
    print("Number is : " + str(result + 1))
else:
    print("No Number!")
   

And this is the output:

Number is : 4

Answer

You return the index i instead of returning the value in the list, arr[i].

Try this:

def findLargestNumberinArray(arr):
    for i in range(len(arr)):
        if (arr[i] > 10):
            return arr[i]
    return -1
    
arr = [1, 9, 3, 27, 0.5, 4, 16, 2]
result = findLargestNumberinArray(arr)
if result != -1:
    print("Number is : " + str(result))
else:
    print("No Number!")