+ 1

linear search in python using list

def linear_search(num): for j in l: if l[i] == num: return i return -1 l=[] for i in range(int(input("Enter size"))): a = int(input("Enter no:")) l.append(a) b = int(input("Enter no to be searched")) linear_search(b) print(i) answer is coming 4 intead of 2 Help me out

23rd Sep 2020, 10:08 AM
Navneet
1 ответ
+ 1
What are inputs you gave?
23rd Sep 2020, 10:13 AM
Vadivelan