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
import time
while True:
# Variables & Big Catching
age = input('What year where you born? ')
current_time = datetime.datetime.now().year
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() and len(age) == 4:
int_age = int(age)
if int_age < 1900:
print('Please enter a valid year!')
quit()
elif int_age > current_time:
print('Please enter a valid year!')
quit()
final_age = current_time - int_age
print('You are', final_age, 'or', final_age - 1, 'years old')
time.sleep(1)
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