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.
ele=input('Enter the elements(numbers) of your list separated by a comma ')
list=ele.split(",")
ele_to_find=input('Enter the element from the list whose index you want to find ')
count=0
if ele_to_find in list:
for ele in list:
if ele==ele_to_find:
print('Index of the element entered is {} '.format(count))
else:
count +=1
else:
print('-1')
Enter the elements(numbers) of your list separated by a comma 2,3,4,5,6,7,8
Enter the element from the list whose index you want to find 7
Index of the element entered is 5
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/aneeshtickoo2002/unfurling-python-assignment-2