python calculate age from date of birth
from datetime import date
def calculate_age(born):
today = date.today()
return today.year - born.year - ((today.month, today.day) < (born.month, born.day))
python calculate age from date of birth
from datetime import date
def calculate_age(born):
today = date.today()
return today.year - born.year - ((today.month, today.day) < (born.month, born.day))
age check python
# Imports
import datetime
# Variables & Big Catching
age = input('What year where you born? ')
if age.isdigit() is False:
print('Please enter a number')
quit()
elif len(age) != 4:
print('Please enter a valid year!')
quit()
elif age.isdigit() is True and len(age) == 4:
int_age = int(age)
current_time = datetime.datetime.now().year
print('You are', current_time - int_age, 'Years old')
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us