Reputation: 13
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.
Upvotes: 1
Views: 40
Reputation:
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
Upvotes: 0
Reputation: 4833
input()
returns a type of str
and this is probably where your issue is coming from. Instead convert to int
after taking input such as
temp1 = int(input())
Upvotes: 1