Skip to content
Advertisement

I keep getting a TypeError and want the program to average a list

I keep getting the error – TypeError: unsupported operand type(s) for +: ‘int’ and ‘str’

temp = []
temp1 = input(int())
temp.append(temp1)

average = sum(temp)/len(temp)
print(average)

I have excluded most of the input code as it is long and not optimized.

Advertisement

Answer

it might be int(input()) not input(int()) instead. :D

because int() is 0, but input() argument is a string not int, so that the error occurs

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement