x in my_iterable
my_iterable : iterable input.x not in my_iterable
my_iterable : iterable input.my_list=[3,4,5,8,3]
if(5 in my_list):
print("Yes it is Present")
else:
print("NO it is NOT Present")
Output
Yes it is Present
Example:
my_list=[3,4,5,8,3]
if(9 in my_list):
print("Yes it is Present")
else:
print("NO it is NOT Present")
Output
NO it is NOT Present
my_list=[3,4,5,8,3]
if(9 not in my_list):
print("Yes it is NOT Present")
else:
print("NO it is Present")
Output
Yes it is NOT Present
for i in range (0,5):
print(i,end=',')
Output
0,1,2,3,4,
url='plus2net.com'
if( '2' in url):
print("yes 2 is available inside")
else:
print("No 2 is not available inside ")
Output
yes 2 is available inside
We will use Dictionarymy_dict={0:'A',1:'B'}
print(1 in my_dict) # True
my_dict={0:'A',1:'B'}
print('A' in my_dict) # False
my_dict={'A':'X','B':'Y','C':'Z'}
print('X' in my_dict) # False
print('C' in my_dict) # True
print('Y' not in my_dict) # True
We will use tuplemy_tuple=(6,1,12,7)
print(7 in my_tuple) # True
my_tuple=(6,1,12,7)
print(8 not in my_tuple) # True
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.