I am writing a little .py program which gives answer depending on user's answer. Code looks like this:
name = input("Please enter your name: ")
age = input("Please tell me your age: ")
date_of_birth = 2020 - int(age)
date_of_birth = str(date_of_birth)
print("Hi! " + name + " you was born in " + date_of_birth)
answer = input("If this is true, write: \"yes\" if now=t, write: \"no\" ")
if answer.upper() == ("YES"):
print("In this year Canada introduced new coin")
elif answer.upper() == ("NO"):
print("If the year of your birth is not 1989, then I need to update my knowledge and get back to you")
My question is related to below lines:
date_of_birth = 2020 - int(age)
date_of_birth = str(date_of_birth)
print("Hi! " + name + " you was born in " + date_of_birth)
As you can see, I had to change variable date_of_birth to string. Is it possible to shorten the code? I would like to avoid changing this variable type into a string. How I could write the line print(...) to shorten the code?
I am not looking for ready answer. I am kindly asking for showing me way of thinking to solve this problem. Thank you.