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.
One approach would not be to test, but to insist. This means your program can handle a broader range of inputs intelligently -- it won't fail if someone passes it a float instead.
int_list = [int(x) for x in int_list]
or (in-place):
for i, n in enumerate(int_list):
int_list[i] = int(n)
If something can't be converted, it will throw an exception, which you can then catch if you care to.