for loop body starts with colon.
The indentation shows the body contents.
EXAMPLES
for i in range(0,5):
print(i)
for i in range(0,5):
if i == 3:
continue
print(i)
for i in range(0,5):
if i == 3:
break
print(i)
for i in range(0,10,3):
print(i)
Last example also have a "step" parameter.
OUTPUT
0
1
2
3
4
0
1
2
4
0
1
2
0
3
6
9
No comments:
Post a Comment
Note: only a member of this blog may post a comment.