TypeError: unsupported operand type(s) for /: 'str' and 'int' - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: TypeError: unsupported operand type(s) for /: 'str' and 'int' (/thread-30034.html) |
TypeError: unsupported operand type(s) for /: 'str' and 'int' - enderfran2006 - Oct-01-2020 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
RE: What? - buran - Oct-01-2020 input will return str you need to convert it to float or int using some built-in function in order to do calculationsthen read on operator precedence |