>>> letters = [a,b,c,d,e]
>>> 'a' in letters:
True
l1 = [1]
l2 = [2,3,4]
if len(set(l1).intersection(set(l2)))==0:
print('1 is not in the list (l2)')
else: # len()>0
print('1 is in the list (l2)')
# plz suscribe to my youtube channel -->
# https://www.youtube.com/channel/UC-sfqidn2fKZslHWnm5qe-A
fruits = ["apple", "banana", "cherry","banana"]
item = "apple"
if item in fruits:
print("Yes, '",item,"' is in the fruits list")
if ourlist.count('to') > 0:
print('"to" exists in ourlist');
#This is the list. You can place it in other file and import it.
"In the same file:"
MyList = ["something", "something2", "something3"]
IncredibleWord = "something"
if IncredibleWord in MyList:
print("Yes, IncredibleWord is in your list")
else:
print("No, IncredibleWord isn't in your list")
#------------------------------------------------------------------------------
"If your list is in an other file:"
#OtherFile
MyList = ["something", "something2", "something3"]
#MyMainFile
#Variables and lists for example
from OtherFile import *
IncredibleWord = "something"
if IncredibleWord in MyList:
print("Yes, IncredibleWord is in your list")
else:
print("No, IncredibleWord isn't in your list")
#-------------------------------------------------------------------------------
#Only a variable or a list for example
from OtherFile import <List Name>
IncredibleWord = "something"
if IncredibleWord in MyList:
print("Yes, IncredibleWord is in your list")
else:
print("No, IncredibleWord isn't in your list")