import datetime
today = datetime.datetime.now()
def bYear():
age = input("How old are you: ")
bYear = today.year - age
print("Born in: " + bYear)
bYear()
I've started learning python a few days ago. Trying some 'stupid' stuff but I can't get this code working.
If i try to print the year with:
print(today.year)
the output is correct.
Error message:
<ipython-input-1-0eeb398a7422> in <module>
5 bYear = today.year - age
6 print("Born in: " + bYear)
----> 7 bYear()
<ipython-input-1-0eeb398a7422> in bYear()
3 def bYear():
4 age = input("How old are you: ")
----> 5 bYear = today.year - age
6 print("Born in: " + bYear)
7 bYear()
TypeError: unsupported operand type(s) for -: 'int' and 'str'```
Im missing something here, any help?