I am attempting to calculate the age of a person from their date of birth entered, using python.
I have already tried this and this but have not found the answer.
I have done the following :
Import datetime, date
from datetime import datetime, date
Create the following notation:
print ('Enter your date of birth here (dd mm yyyy): ')
date_of_birth = datetime.strptime(str(input('----->')), '%d %m %Y')
def calculate_age(born):
today = date.today()
return today.year - born.year - (( today.month, today.day) < (born.month, born.day))
age = calculate_age(date_of_birth)
print (age)
However when I enter the date in this format 9121991
:
I get this value error.
Incidentally when I enter it in this 09121991
format, I recieved this error
How can I correct this?