import datetime
print("##### Welcome to age calculator ######")
birth_year = int(input("Enter your year of birth: \n"))
birth_month = int(input("Enter your month of birth: \n"))
birth_day = int(input("Enter your day of birth: \n"))
current_year = datetime.date.today().year
current_month = datetime.date.today().month
current_day = datetime.date.today().day
age_year = current_year - birth_year
age_month = abs(current_month-birth_month)
age_day = abs(current_day-birth_day)
print("Your exact age is: ", age_year, "Years", age_month, "months and", age_day, "days")
Output should look like something:
##### Welcome to age calculator ######
Enter your year of birth:
1986
Enter your month of birth:
05
Enter your day of birth:
25
Your exact age is: 34 Years 2 months and 2 days
Rate this:
When you learn, know it / When you know, Share it:
I am a virtualization and cloud Consultant. Also a VCI and MCT. I am in IT industry since last 13 years and worked across various technologies. vExpert since 2016-present
View all posts by Abhijeet D