Note: Colon
If else
If ...:
Indent
Else:
Indent
If Guess = Number:
Print ' Congratulations, you guessed it. ' # New block starts here
Running = False
Elif Guess < Number:
Print ' No, it is a little higher than that ' # Another block
# You can do whatever you want in a block...
Else :
Print ' No, it is a little lower than that '
# You must have guess> number to reach here
Switch
No switch. Replace it with if...: Elif...: else :.
While
While XX:
Indent
Else:
Indent
While Done = False:
I = I + 1 ;
Print ' Frame ' , I
Else :
Print ' The while loop is over. '
For
For element in Arrays:
Indent
Else:
Indent
For I In Range ( 1 , 5 ):
Print I
Else :
Print'The for loop is over'
Break
Terminate the cycle.
Note:If you terminate a for or while loop, no corresponding loop else block will be executed.
Continue
The statement following this loop is escaped and enters the next loop.
Note:The continue statement is also valid for the for loop.