/* */

Wednesday 23 March 2011

Creating Dictioanries

phonebook = {'Alice' : '2341', 'Beth' : '9102', 'Cecil' : '3258'}

Phone books consist of pairs - their 'key' and irs corresponding item.
e.g. the key 'Alice' has a value of '2341'.
This script has expressed the values as 'strings' and not integeres in order to avoid them being interpreted as octagonal numbers.

Creating an empty dictionary is written:

phonebook = {}

No comments:

Post a Comment