Created
July 26, 2017 17:34
-
-
Save rostyq/f20629511db2de372bf2b284211b380c to your computer and use it in GitHub Desktop.
Exercise on www.practicepython.org
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import strftime | |
now = int(strftime("%Y")) | |
name = input("What is your name?\n->") | |
years = list(range(100)) | |
while True: | |
try: | |
age = int(input("How old are you?\n->")) | |
if age not in years: | |
raise ValueError | |
break | |
except ValueError: | |
print("Please, write a natural number less 100.") | |
continue | |
while True: | |
try: | |
times = int(input("How many times print the answer?\n->")) | |
break | |
except ValueError: | |
times = 1 | |
print("Your input is not understandable. Set to 1.") | |
break | |
left = 100 - age | |
year100 = now + left | |
print(times * "{0}, you will be 100 years old in {1}. {2} years left.\n".format(name, year100, left)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment