Iteration - For loops
for.py
for x in range(6): #stop at 6 print(x)
start stop.py
for x in range(10,20): #start at 10, stop at 20 print(x)
start stop step.py
for x in range(20, 10, -2): #start at 20, stop at 10, jump or step by -2 each iteration print(x)Using a FOR loop:
- Count upwards from -20 to 0, jumping 3 numbers at a time.
- input a whole integer, and count down from that integer to 1. after 1 my program should say "blast off!".
- in the while loop example we used the word
continue
to skip an iteration. Use a for loop to count from 1 to 5, skipping the number 3 (how you do this is up to you).