diff --git a/thinkcspy/Chapter-13-Exercises/readposint.py b/thinkcspy/Chapter-13-Exercises/readposint.py new file mode 100644 index 0000000..51dbb5d --- /dev/null +++ b/thinkcspy/Chapter-13-Exercises/readposint.py @@ -0,0 +1,11 @@ +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: ")) \ No newline at end of file