While you're here...why is my code correct?


#1

Hello

I noticed that some coded as follows -

count = 0

if count < 10: // or count <= 9
    print "Hello, I am an if statement and count is"

while count < 10 // or count <= 9
    print "Hello, I am a while and count is", count
    count += 1

I coded the following -

count = 0

if count <= 9:
    print "Hello, I am an if statement and count is", count
    
while count < 10:
    print "Hello, I am a while and count is", count
    count += 1

Got the same result and green bookmark. But why is mine correct? \must \i have included the parentheses?
Thanks


#2

This,

and this,

are invalid syntax.

Your code is correct because it runs as desired. :slight_smile:


#3

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