python check if int is in list code example
Example 1: check if list of list python
for item in list_of_lists:
isinstance(item, list)
Example 2: python check if int
colors = [11, 34.1, 98.2, 43, 45.1, 54, 54]
for x in colors:
if int(x) == x:
print(x)
#or
if isinstance(x, int):
print(x)
Example 3: how to check if value is in list python
>>> letters = [a,b,c,d,e]
>>> 'a' in letters:
True
Example 4: check if a number is in a list python
5 in [3, 4, 5, 6, 7]
# True
9 in [3, 4, 5, 6, 7]
# False