9 lines
283 B
Python
9 lines
283 B
Python
from datetime import date
|
|
|
|
def calculate_age(dtob):
|
|
today = date.today()
|
|
return today.year - dtob.year - ((today.month, today.day) < (dtob.month, dtob.day))
|
|
print()
|
|
print(calculate_age(date(2006,10,12)))
|
|
print(calculate_age(date(1989,1,12)))
|
|
print() |