Basic python program to check if element exists in list. In this program we can check the number or element exist in the list or not using python programming language.
List Definition in Python
In Python, a list is a data structure that is a mutable (or changeable) ordered sequence of elements. A list’s items are the elements or values that make up the list. Lists are defined by values between square brackets  in the same way that strings are defined by characters between quotes.
A list is made in Python by putting elements inside square brackets  and separating them with commas. A list can contain any number of items of various types, such as integers, floats, strings, and so on. learning python programming as a beginner is easy
For Definition in Python
In Python, a for loop is a control flow statement that is used to execute a set of statements repeatedly as long as the condition is met. An iterative statement is another name for this type of statement.
A for loop is thus an iterative statement. Python for loops are commonly used in data science to loop through an iterable object such as a list, tuple, set, etc. and perform the same action for each entry. A for loop, for example, allows us to iterate through a list of items, performing the same action on each one. Here we have executed the python program to check if element exists in list using for loop.
Python Program to Check If Element Exists in List
list = [ 1, 6, 3, 5, 3, 4 ] print("Checking Number 3 is the List or Not") for i in list: if(i == 3) : print ("Element Exists") print("Checking Number 4 is the List or Not") if (4 in list): print ("Element Exists")
Checking Number 3 is the List or Not
Checking Number 4 is the List or Not