/* */

Thursday 24 March 2011

String formatting with Dictionaries

phonebook = {'Beth' : '9102' , 'Alice' : '2341' , 'Cecil' : '3228' }
"Cecil's phone number is %(Cecil)s." %phonebook
"Cecil's phone number is 3258."

The (Cecil) points to that particular key, 'phonebook' directs towards the dictionary.

No comments:

Post a Comment