[Tutor] Loops

Marcus Lütolf marcus.luetolf at bluewin.ch
Sun Apr 5 13:11:06 CEST 2015


Why do I get this traceback with the infinite loop below but not with the
definitw loop (bottom of mail)?
Thanks for help, Marcus.

 

count = 0

total = 0

while True:

    x = raw_input('Enter a number')

    count = count + 1

    total = total + x

    print count, total, (total/count)

 

 

Traceback (most recent call last):

  File "C:\Python27\enter_a_number.py", line 6, in <module>

    total = total + x

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



---
Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.
http://www.avast.com


More information about the Tutor mailing list