Course Home
Announcements
Check Yourself
Python Errors in English
CodeSkulptor FAQ
Reflections

Online Lessons

Related Links

Online Development

Lessons

Reference

eBooks

Dictionaries

Dictionaries are related to lists. They are both collections of items.

List example:
>>> l = []
>>> l.append('alpha')
>>> l.append('gamma')
>>> l.append('omega')
>>> l = ['alpha', 'gamma', 'omega']
>>> l[1]
'omega'
>>> l.insert(1, 'beta')
>>> l
['alpha', 'beta', 'gamma', 'omega']
>>>
Dictionary example:
>>> d = {}
>>> dict['a'] = 'alpha'
>>> dict['g'] = 'gamma'
>>> dict['o'] = 'omega'
>>> d
{'a': 'alpha', 'o': 'omega', 'g': 'gamma'}
>>> d['b'] = 'beta'
>>> d
{'a': 'alpha', 'b': 'beta', 'o': 'omega', 'g': 'gamma'}
>>>

dict with keys 'a' 'o' 'g'

What are dictionaries good for?

This short video is a bit technical, but if you're familiar with the workings of http, you might find it interesting.

CodeAcademy Lessons

Work through the following CodeAcademy lessons to further solidify your understanding:

Section: LISTS & DICTIONARIES -> Python Lists and Dictionaries -> Dictionaries (10-14)

Section: LISTS & DICTIONARIES -> A Day at the Supermarket

Section: STUDENT BECOMES THE TEACHER (all)

Section: ADVANCED TOPICS IN PYTHON -> Advanced Topics in Python -> Iteration Nation (1-3)

Quizlet

Work through the following Quizlet until you have committed the terms to memory.

Quiz

Try this dictionaries quiz to test your dictionary knowledge.