Google News
logo
Python Program to Check if a List item exists
To check if an element exists in a list, we can use the `in` operator. Here's an example program :
Program :
my_list = [1, 2, 3, 4, 5]

# Check if an element exists in the list
if 3 in my_list:
    print("3 is present in the list")

if 6 not in my_list:
    print("6 is not present in the list")
Output :
3 is present in the list
6 is not present in the list