Age calculator
Age calculator
You will required to enter following credential - Enter your name
Your birth year
Then a program will return your name and current age in number
Source Code: age1.py
from datetime import date
from dateutil.relativedelta import relativedelta
n = input("Enter your name buddy ")
birth_str = input('Enter the date you were born, in format YYYY-MM-DD: ')
try:
birth = date.fromisoformat(birth_str)
except ValueError:
print("Don't you know your birthday?")
exit()
age = relativedelta(date.today(), birth)
print(f'Wohoo {n} is {age.years} years, {age.months} months and {age.days} days old.')