In [115]:
# Pseudocode:
# Assume index = 0
# for number in the input_list
# count the number
# if given number is in the list
# return the index = n-1, because index starts from 0
# if it is not in the list
# return sorry

In [116]:
def to_index(input_list,a):
    n = 0
    for item in input_list:
        n = n + 1
        if item == a:
            index = n - 1 
            return "The index of given number is:", str(index)
    else:
            return "Sorry, can't find the numer."

In [118]:
import random

In [113]:
test_10 = random.sample(range(1,1000), 10)
# %time to_index(test_10,5)
# CPU times: user 6 µs, sys: 1 µs, total: 7 µs
# Wall time: 11 µs
# Out[12]:"Sorry, can't find the numer."

In [103]:
test_100 = random.sample(range(1,1000), 100)
# %time to_index(test_100, 12)
# CPU times: user 8 µs, sys: 1 µs, total: 9 µs
# Wall time: 11 µs
# Out[102]:('The index of given number is:', '19')

In [110]:
test_1000 = random.sample(range(1,10000), 1000)
# %time to_index(test_1000, 23)
# CPU times: user 120 µs, sys: 1 µs, total: 121 µs
# Wall time: 124 µs
# Out[109]: "Sorry, can't find the numer."