Use list.
>>> t = ['Jack', 18, 'IM-101', 99.9] >>> [x for x in t if type(x) == type(1)] [18] >>>
map (int, x) throws an error
The map function applies int (t) to each x element.
This causes an error because int ('Jack') will throw an error.
[Edit:]
Also, isinstance is a cleaner way of checking that it is of type integer, as the suhbir says.
source share