Advertisement
dino3vr

Untitled

Jan 23rd, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. import datetime
  2.  
  3. now = datetime.datetime.now()
  4. now_year = int(str(now.year))
  5. now_month = int(str(now.month))
  6. now_day = int(str(now.day))
  7.  
  8. birth_day = int(input("Day of birth >>> "))
  9. birth_month = int(input("Month of birth >>> "))
  10. birth_year = int(input("Year of birth >>> "))
  11.  
  12. years = now_year - birth_year if now_month > birth_month else now_year - birth_year - 1
  13.  
  14. months = 12 + now_month - birth_month if now_month < birth_month else now_month - birth_month
  15.  
  16. days = 0
  17.  
  18. if now_day > birth_day:
  19.     days = now_day - birth_day
  20. else:
  21.     days = now_day
  22.    
  23. print(f"Your age is: {years} years {months} months {days} days!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement