Program to find the given element in list using Python


In this section, we will understand the python code to find whether the element is in the list or not. Python provides ‘in’ keyword to easily find the element in the list.

Program to find the given element in list


list = ['is', 'st', 'around', 'in', 'the']

element = input("Enter the preposition to find: ")

# Check if it exists in list

if (element in list):

    print("Element Exists!")


    print("Element does not exists!")



Program to find the given element in list Output


In the above python code, we have created a variable element which takes the user input. Through ‘in’ statement the variable element is checked against each value in list and if the searched value exists in the list the output “Element exists!” is displayed on the screen otherwise “Element does not exists!” is displayed.

The other way to find the element in the list is by converting the list into set first and then applying ‘in’ to the set. The disadvantage of using set() + in is that the duplicate value will get removed.


  • Barry Allen

    A Full Stack Developer with 10+ years of experience in different domain including SAP, Blockchain, AI and Web Development.

    View all posts


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.