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.
b=int(input("enter how many numbers of elements in list you want in the list "))
print("now enter the numbers ")
a=list(map(int,input().split()))[:b]
c=int(input("enter the number of which you need to find index "))
if c in a:
for i in range(0,b):
if a[i]==c:
print("the index is ",i)
break
else :
print(-1)
enter how many numbers of elements in list you want in the list 3
now enter the numbers
1 2 3
enter the number of which you need to find index 2
the index is 1