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(calculate_age(date(1998,10,18)))

Output :

22

Add a Comment

Add a Comment