1. While you're here


Help please.
Change the loop so it counts up to 9 (inclusive).
Be careful not to change or remove the count += 1 bit—if Python has no way to increase count, your loop could go on forever and become an infinite loop which could crash your computer / browser!

count = (0,1,2,3,4,5,6,7,8,9)

if count < 5:
print "Hello, I am an if statement and count is", count

while count < 5:
print "Hello, I am a while and count is", count
count += 1

Oops, try again. Be sure you print all the numbers from 0 to 9 (inclusive).


Why set count = (0,1,2,3,4,5,6,7,8,9)? You already have a while loop which increases the count by 1 each time.

And you wrote while count < 5: when you need to count to 9.


Thanks for the help. I switched it to 9 and it was still wrong, so I set it
to 10 and it worked.


Just in case you were wondering, it's < 10 because < means less than and not including 10.


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