Python Forum

Full Version: Age calculation
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,how can we calculate someones age by using python coding? (In the calculation not only the diffrence between years are needed,the months and days should be used too.)

Can someone help me,

Thank You
Kaan
We are glad to help, but we are not going to do your [home]work for you.
Post your code in python tags, full traceback (if any) - in error tags and ask specific question)s).
For start you may write down how would you solve the problem without computer/script - i.e. step by step, then code each step
This is not my homework.Im just trying to learn to do it because I know that oneday I will need to do this
homework or not - my advise still stands. You need to show effort to solving the problem
https://docs.python.org/3/library/datetime.html
https://www.guru99.com/date-time-and-dat...ython.html
  • Create a date object (birthday)
  • Create a date object (today)
  • Calculate the timedelta (today - birthday), then you get the days