python_exercises/thinkcspy/Chapter-13-Exercises/readposint.py
2023-12-13 09:43:40 -07:00

11 lines
No EOL
324 B
Python

def readposint(num):
try:
val = int(num)
if val > 0:
print("You entered '{}'.".format(val))
else:
print("'{}' is not a positive.".format(val))
except Exception:
print("'{}' is not a number.".format(num))
readposint(input("Please enter a positive number: "))