I am trying to code a program that will ask the user for their name and age and return how long until they turn 100 years old. I keep getting errors and I can't understand what I am doing wrong.
Here is the more basic code I have changed it to try and get it to work, as was getting too much resistance getting my f-strings to print with {age}
, {name}
and so on.
import sys, math
# Inputs
name = str(input("What is your name: "))
age = str(input("How old are you: "))
# Calculations
diff = (100 - age)
year = str((2020 - age)+100)
# Output
print ("Hay " + name + " you are currently " + age + " years old, in " + diff + " years you will be 100, in the year " + year)
at the diff = (100 - age)
stage of my program it comes back with the following:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
~/Documents/Python/years until you are 100.py in
7 # Calculations
8
----> 9 diff = (100 - age)
10
11 year = str((2020 - age)+100)
TypeError: unsupported operand type(s) for -: 'int' and 'str'
What am I missing?