I am getting an operand error in pycharm, and I don’t understand why because in pycharm instant feedback sense, the code is correct.
What is your name?
How old are you?
Traceback (most recent call last):
File "/Users/tiacobb/PycharmProjects/CobbMod2/NameAge.py", line 5, in <module>
year = date.today().year - age
~~~~~~~~~~~~~~~~~~^~~~~
TypeError: unsupported operand type(s) for -: 'int' and 'str'
Please help. Thank you.
Tried:
from datetime import date
name = input("What is your name?")
age = input("How old are you?")
year = date.today().year - age
print("Hello" + name + "!" + "You were born in" + str(year) + ".")
New contributor
user25121123 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.