Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (47.6k points)

How do I check whether a variable is an integer?

 

1 Answer

0 votes
by (106k points)

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))

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...