Python Forum

Full Version: TypeError: unsupported operand type(s) for /: 'str' and 'int'
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am confused to why this doesnt work. Can anyone help?
This is the code
number1 = input("What was the temperature on Monday?")
number2 = input("What was the temperature on Tuesday?")
number3 = input("What was the temperature on Wednesday?")
number4 = input("What was the temperature on Thursday?")
number5 = input("What was the temperature on Friday?")
number6 = input("What was the temperature on Saturday?")
number7 = input("What was the temperature on Sunday?")

total = number1+number2+number3+number4+number5+number6+number7 /7
print("the average temperature was", total, ".")
This is the error
Error:
Traceback (most recent call last): File "C:\Users\Franek\Desktop\Python\Practise of My Skills\temp.py", line 9, in <module> total = number1+number2+number3+number4+number5+number6+number7 /7 TypeError: unsupported operand type(s) for /: 'str' and 'int'
input will return str you need to convert it to float or int using some built-in function in order to do calculations
then read on operator precedence