Python Tutorial | Python List

Question:11
Python program to search an element from a list?
Sol:

n=[21,26,33,46,25,96]
z=0
n1=int(input("Enter element to search "))
print(n)
for i in n:
    if(i==n1):
        z=1
        break
if(z==1):
    print("element is present")
else:
    print("element is not present")
    

Output:

Enter element to search 2
[21, 26, 33, 46, 25, 96]
element is not present
>>>

Enter element to search 33
[21, 26, 33, 46, 25, 96]
element is present
>>>

Visitor Counter

0051135