import datetime
def age_now():
now_time = str(datetime.date.today())
split_time = now_time.split("-")
print("Please enter your date of birth")
b_year = int(input("Year:"))
b_month = int(input("Month:"))
b_day = int(input("Day:"))
age = int(((int(split_time[0]) * 10000 + int(split_time[1]) * 100 + int(split_time[2])) - (b_year * 10000 + b_month * 100 + b_day)) / 10000)
print("Current age{}I'm talented".format(age))
age_now()
It's easy like this. I'm using the int function too much and I'm not sure. If you feel like it, try reducing it.
*** Addendum ***
import datetime
def age_now():
time = str(datetime.date.today())
now_time = int("".join(time.split("-")))
print("Please enter your date of birth")
birthday = int(input())
age = int(((now_time - birthday) / 10000))
print("Current age{}I'm talented".format(age))
age_now()
Something like this. Wasn't the input itself easier for the previous guy? Well this time in a place like this ...
Recommended Posts