Say I have a list of numbers. How would I do to check that every item in the list is an int? I have searched around, but haven\'t been able to find anything on this. >
lst = [1,2,3] lst2 = [1,2,'3'] list_is_int = lambda lst: [item for item in lst if isinstance(item, int)] == lst print list_is_int(lst) print list_is_int(lst2) suxmac2:~$ python2.6 xx.py True False
....one possible solution out of many using a list comprehension or filter()