1

Sometimes upon receiving numeric parameters it is required to check whether the received numeric value is or not is a positive integer value.

How can we do this in python?

  • Welcome to SO. Please take the [tour] and take the time to read [ask] and the other links found on that page. This isn't a discussion forum or tutorial service. You should invest some time working your way through [the Tutorial](https://docs.python.org/3/tutorial/index.html), practicing the examples. It will give you an introduction to the tools Python has to offer for solving your problem. – wwii Sep 14 '19 at 13:22

1 Answers1

0

One simple way:

if isinstance(number, int) and number > 0:
    # number is a positive integer
Dipen Dadhaniya
  • 4,550
  • 2
  • 16
  • 24