confusion with input data type
As a new user learning Python, why does the if conditional fails when entered mth is greater than cur_mth? as i understand the input statement is character and using the int converts the mth and cur_mth to integer. I thought both would be integer, yet must not be because the if conditional does not go True. What am I missing? Thank you in advance
from datetime import datetime
import calendar
cur_yr = int(dt.year)
cur_mth = int(dt.month)
start_year = int(input("Enter your birth year: "))
mth = int(input("Enter your birth month as 1 to 12: "))
if mth > cur_mth:
cur_yr = cur_yr -1
print ('current year less one: ', cur_yr)
age = cur_yr - start_year
print (f"Your are {age} years old")
Please sign in to leave a comment.