Learn practical skills, build real-world projects, and advance your career
Updated 3 years ago
!pip install jovian --upgrade --quiet
import jovian
Question 1: The user will enter a list of numbers and a separate number. The program will display the index at which the number is present in the list. If the number is absent, it'll return -1. Do NOT use built-in functions for searching.
input1=[]
n=int(input('enter the length of the list'))
dum1=1
while (dum1<=n):
dum1=dum1+1
ele1=input()
input1.append(ele1)
enter the length of the list5
1
5
2
3
6
m=input()#The number we want to match from the list
i=1
k=input1[0]
while(i<=n):
t=input1[i]
i=i+1
if(m==t):
break
elif(not(m in input1)):
i=-1
break
print('The index is ' + str(i))
5
The index is 2