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.
a=input("enter the list")
list=a.split()
b=int(input())
if str(b) in list:
for i in range(0,len(list)):
if list[i]=b:
else :
print(-1)
enter the list1 2 3
2
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-16-358c77eef796> in <module>
4 b=int(input())
5 if str(b) in list:
----> 6 print(c.index(b))
7 else :
8 print(-1)
ValueError: 2 is not in list