- for is ideal for lists
- break breaks out of the smallest block
- continue jumps to the next iteration
Python Iteration Statements Example 1
for i in range(10): print i
Python Conditional Statements Example 2
for i in [0,1,2,3,4,5,6,7,8,9]: print i
Python Conditional Statements Example 3
a = ['think', 'try'] for x in a: print x + 'ing' # prints thinking and trying
Python Conditional Statements Example 4
# print odd numbers between 1 and 10 for i in range(10): if i % 2 == 0: continue print i
Python Conditional Statements Example 5
# finds the number 5 in the list x = 5 for i in range(10): print i if i == x: print 'found it' break