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
1f = 1.23
2
3print(f.is_integer())
4# False
5
6f_i = 100.0
7
8print(f_i.is_integer())
9# True
10
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))