0

Code

add = 0

i = 10
while i>0:
    print ("Enter number")
    num = input()
    add = add + num
    i = i-1
print ("average is",add/10.0)

Error:

TypeError: unsupported operand type(s) for +: 'int' and 'str'

sshashank124
  • 31,495
  • 9
  • 67
  • 76
Rahul
  • 1
  • 1
    `input()` returns a string, not an integer. You need to convert it to `int` using `int(input())`. – Ajay Dabas Jan 14 '20 at 05:41
  • 1
    Whatever you enter as input, input function convert it into a string. If you enter an integer value still input() function convert it into a string. You need to do the explicit conversion into an integer in your code. – Adam Strauss Jan 14 '20 at 05:44
  • oh, I see. Thanks – Rahul Jan 15 '20 at 10:17

0 Answers0