Back
How do I check whether a variable is an integer?
To check whether a variable is an integer or not you need to do this, do:-
isinstance(<var>, int)
If you are using Python 2.x in which case you want to do something like as follows:-
isinstance(<var>, (int, long))
30.9k questions
32.9k answers
500 comments
665 users