21 lines
398 B
Python
21 lines
398 B
Python
import datetime
|
|
|
|
|
|
def prompt_user():
|
|
name = input('What is your name? ')
|
|
try:
|
|
age = int(input('How old are you? '))
|
|
except ValueError:
|
|
return 'Age must be a number.'
|
|
|
|
return 'Hello {0}! You were born in {1}.'.format(name, get_year() - age)
|
|
|
|
|
|
def get_year():
|
|
now = datetime.datetime.now()
|
|
return now.year
|
|
|
|
|
|
if __name__ == '__main__':
|
|
print(prompt_user())
|