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?

1
  • Welcome to SO. Please take the tour and take the time to read How to 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, practicing the examples. It will give you an introduction to the tools Python has to offer for solving your problem. Commented Sep 14, 2019 at 13:22

1 Answer 1

0

One simple way:

if isinstance(number, int) and number > 0:
    # number is a positive integer
Sign up to request clarification or add additional context in comments.

Comments