18.11.2014 Views

Zelle - Chapter 11.pdf - CTools

Zelle - Chapter 11.pdf - CTools

Zelle - Chapter 11.pdf - CTools

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Looping Through Dictionaries<br />

• We loop through the<br />

key-value pairs in a<br />

dictionary using *two*<br />

iteration variables<br />

• Each iteration, the first<br />

variable is the key and<br />

the the second variable is<br />

the corresponding value<br />

>>> jjj = { 'chuck' : 1 , 'fred' : 42, 'jan': 100}<br />

>>> for aaa,bbb in jjj.items() :<br />

... print aaa, bbb<br />

...<br />

jan 100<br />

chuck 1<br />

aaa bbb<br />

fred 42<br />

[jan] 100<br />

>>><br />

[chuck] 1<br />

[fred] 42

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!