5/14 Infinite loops


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!
<Look to the right of this box. That is how your post will look to everyone else.

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>

<What do you expect to happen instead?>

``` 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

<do not remove the three backticks above>

#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

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!
<Look to the right of this box. That is how your post will look to everyone else.

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>

<What do you expect to happen instead?>

``` 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

<do not remove the three backticks above>

#4

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!
<Look to the right of this box. That is how your post will look to everyone else.

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>

<What do you expect to happen instead?>

``` I kinda followed the example:

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

<do not remove the three backticks above>

#5

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

    print count 
    count += 1

#6

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!
<Look to the right of this box. That is how your post will look to everyone else.

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>

<What do you expect to happen instead?>

``` Thank you so much!

count = 0

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

It worked!

<do not remove the three backticks above>