1'16'.isdigit()
2>>>True
3
4'3.14'.isdigit()
5>>>False
6
7'Some text'.isdigit()
8>>>False
1
2colors = [11, 34.1, 98.2, 43, 45.1, 54, 54]
3
4for x in colors:
5 if int(x) == x:
6 print(x)
7
8 #or
9 if isinstance(x, int):
10 print(x)
11
1# From stackoverflow
2# If you need to do this, do
3
4isinstance(<var>, int)
5
6# unless you are in Python 2.x in which case you want
7
8isinstance(<var>, (int, long))