write a python program to search for an element in a given list of numbers

python programming

write a python program to search for an element in a given list of numbers

--------------------------------------------------------
Solution:-

li=[1,50,35,909,651,22,15,3,7,65]
num=int(input("Enter the number to be searched : "))
found=0
for a in li:
    if a==num:
        print("Given Item found at the Position : ",li.index(num)+1)
        found=1
if found==0:
    print("Given Item not found in list")

--------------------------------------------------------
Output-1

Enter the number to be searched : 50
Given Item found at the Position :  2

Output-2

Enter the number to be searched : 10
Given Item not found in list

Post a Comment

0 Comments