Skip to content

Instantly share code, notes, and snippets.

@rostyq
Created July 26, 2017 17:34
Show Gist options
  • Save rostyq/f20629511db2de372bf2b284211b380c to your computer and use it in GitHub Desktop.
Save rostyq/f20629511db2de372bf2b284211b380c to your computer and use it in GitHub Desktop.
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