5/14 Infinite loops


#1


Hi, I'm stuck at this code, and I don't know what's going on.

count = 0

while count < 10:
    # Add a colon
    print count -= 1
    # Increment count

Codecademy says, "Oops, try again. Did you remember to add in the colon on line 3?"    
    # I thought I did add?!

Console prints,  
File "python", line 5
    print count -= 1
                 ^
SyntaxError: invalid syntax




#2

Increment is print count += 1

count is variable that hold's value of 0

while count is smaller than 10 you increment count by one
is 0<10, yes it is print 0 and set count to 1
is 1<10, yes it is print 1 and set count to 2 and so on till 10<10


#3


Erm, it still does not work:

count = 0

while count < 10:
    # Add a colon
    print count += 1
    # Increment count

Codecademy says, "Oops, try again. Did you remember to add in the colon on line 3?"    

Console prints,  
File "python", line 5
    print count -= 1
                 ^
SyntaxError: invalid syntax




#4


I kinda followed the example:

count = 10
while count > 0:
    count += 1 
    # Instead of count -= 1


#5

told you increment is +=, decrement is -=
and you can't print and do increment or decrement

    print count 
    count += 1

#6


Thank you so much! 

count = 0

while count < 10:
    # Add a colon
    print count
    count += 1
    # Increment count

It worked!