Learn practical skills, build real-world projects, and advance your career
Created 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.
l=[]
for a in range (int(input('The length of list should be : '))):
b=int(input('Enter element '+str(a+1)+': '))
l.append(b)
c=int(input('Enter element to find the index no. : '))
if c in l:
for x in range(len(l)):
if c==l[x]:
print('The element',c,' is at index',x)
break
else:
continue
else:
print('1')
The length of list should be : 4
Enter element 1: 1
Enter element 2: 2
Enter element 3: 3
Enter element 4: 4
Enter element to find the index no. : 2
The element 2 is at index 1 or 2 position.
jovian.commit(project='shashwatjaiswal2001/unfurling-python-assignment-2')
[jovian] Attempting to save notebook..
[jovian] Uploading notebook..
[jovian] Uploading additional files...
[jovian] Committed successfully! https://jovian.ai/sanattudu/unfurling-python-assignment-2