In [13]:
tup = [(1,2), (3, 4), (5,6)]

In [14]:
for t in tup:
    print(t)


(1, 2)
(3, 4)
(5, 6)

In [18]:
[(t1, t2) for (t1, t2) in tup]


Out[18]:
[(1, 2), (3, 4), (5, 6)]

In [4]:
# tuple unpacking

In [7]:
for t1, t2 in tup:
    print(t1)
    print(t2)


1
2
3
4
5
6

In [15]:
dic = { "k1": None, "k2": "value 2", "k3": "value 3"}

In [16]:
for key in dic:
    print(key)


k3
k2
k1

In [19]:
print(dic["k2"])


value 2

In [20]:
# python 3
for k,v in dic.items():
    print(k, v)


('k3', 'value 3')
('k2', 'value 2')
('k1', None)

In [21]:
# python 2
for k,v in dic.iteritems():
    print(k, v)


('k3', 'value 3')
('k2', 'value 2')
('k1', None)

In [27]:
#basics
x = 0
while x < 10:
    print "x is currently:", x
    x += 1


x is currently: 0
x is currently: 1
x is currently: 2
x is currently: 3
x is currently: 4
x is currently: 5
x is currently: 6
x is currently: 7
x is currently: 8
x is currently: 9

In [10]:
# break continue pass
y = 0
while y < 12:
    print 'x is', y
    if y == 4:
        # pass # does nothing
        print 'continue'
        y += 4
        continue
    if y == 10:
        print 'break'
        break # breaking breaks out of while and doesn't run else
    y += 1
else:
    print 'we\'ve finished'


x is 0
x is 1
x is 2
x is 3
x is 4
continue
x is 8
x is 9
x is 10
break

In [ ]: