Programming Example

WAP to search for an element in a given list of numbers.

Solution

L=[2,58,95,999,65,32,15,1,7,45]
n=int(input("Enter the number to be searched : "))
found=0
for x in L:
    if x==n:
        print("Item found at the Position : ",L.index(n)+1)
        found=1
if found==0:
    print("Item not found in list")
Output

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

===============================

Enter the number to be searched : 15
Item found at the Position :  7


CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Website development Company in Allahabad