While, break and continue


#1




https://www.codecademy.com/en/courses/python-beginner-en-fymF4/5/8


The code gets the num and then shows an error massage:
"Traceback (most recent call last):
File "python", line 9, in
TypeError: unsupported operand type(s) for -: 'unicode' and 'int' "


num=1
while num>0:
    num=raw_input("Enter a number:")
    if num==0:
       continue
    if num<0:
       break
    if num>0:
        print num/2


thank you for the help :slight_smile:


#2

normally raw_input stores input as string, but in codecdemy this unicode

so if we then read the error again:

TypeError: unsupported operand type(s) for -: 'string' and 'int' "

you should cast the user input to a integer


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.