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.
l1=list(input('Enter a list of numbers:'))
n= input('Enter the number you want the index of:')
i=0
ind=0
flag=0
for i in range(0,len(l1)):
if n==(l1[i]):
ind=i
flag=1
if flag==1:
print('{} found at index {}'.format(n, ind))
else:
print(-1)
Enter a list of numbers:12345
Enter the number you want the index of:5
5 found at index 4