List Methods in Python - Set 1 (In, Not In, Len, Min, Max )
List Methods in Python - Set 1 (In, Not In, Len, Min, Max )
min(), max()…)
List basics have been covered in python in the set below
1. “in” operator :- This operator is used to check if an element is present in the list or
not. Returns true if element is present in list else returns false.
2. “not in” operator :- This operator is used to check if an element is not present in
the list or not. Returns true if element is not present in list else returns false.
Output:
6. “+” operator :- This operator is used to concatenate two lists into a single list.
7. “*” operator :- This operator is used to multiply the list “n” times and return
the single list.
# Python code to demonstrate the working of
# "+" and "*"
# initializing list 1
lis = [1, 2, 3]
# initializing list 2
lis1 = [4, 5, 6]
# using "+" to concatenate lists
lis2= lis + lis1
# priting concatenated lists
print ("list after concatenation is : ", end="")
for i in range(0,len(lis2)):
print (lis2[i], end=" ")
print ("\r")
#using '*' to combine lists
lis3 = lis * 3
# priting combined lists
print ("list after combining is : ", end="")
for i in range(0,len(lis3)):
print (lis3[i], end=" ")
Output:
Output: