Basic Python Program-11

Write a program to search an element in the list using for loop and also demonstrate the use of else with for loop



lst=[1,2,3,10,11,20,30]

x=int(input("Enter element you want to search"))
flag=0

for i in lst:
    if(i==x):
        flag=1
        print(x, "is present in the list")

else:
    if(flag==0):
       print(x,"is not present in the list")