From 7691e18a5a522801eed023b39ccd69c3cf59137b Mon Sep 17 00:00:00 2001 From: Jeffrey Elkner Date: Fri, 19 May 2023 10:36:42 -0400 Subject: [PATCH] Add how_old.py example for chapter 3 --- PY4E/ch03/how_old.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 PY4E/ch03/how_old.py diff --git a/PY4E/ch03/how_old.py b/PY4E/ch03/how_old.py new file mode 100644 index 0000000..00d034d --- /dev/null +++ b/PY4E/ch03/how_old.py @@ -0,0 +1,8 @@ +age = input("How old are you? ") + +while not age.isnumeric(): + age = input("Please enter only digits. Try again. How old are you? ") + +age = int(age) +print("Great, your are", age, "years old. Next year you'll be", age+1, "!") +