From 7caa92278e45ef3aa90999dcec1e30a13ac8656c Mon Sep 17 00:00:00 2001 From: matteorr88 Date: Tue, 23 Apr 2024 21:54:11 +0200 Subject: [PATCH] added the solution to 008 --- projects/008-dog-years/python/main.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/projects/008-dog-years/python/main.py b/projects/008-dog-years/python/main.py index e69de29..9f9f7be 100644 --- a/projects/008-dog-years/python/main.py +++ b/projects/008-dog-years/python/main.py @@ -0,0 +1,13 @@ +human_years = int(input("Enter the age you want to convert into dog years!")) + +if human_years < 0: + print("Error: please enter a non negative number.") +elif human_years < 2: + print(human_years,"Human years =",human_years * 10.5, "dog years") +else: + dog_first_2_years = 2 * 10.5 + dog_remaining_years = (human_years - 2) * 4 + total_years = dog_first_2_years + dog_remaining_years + + print(human_years,"Human years =", format(total_years,'.0f') + " dog years") +