"Harlin Seritt" <ha**********@yahoo.com> writes:
groups = {'IRISH' : 'green', 'AMERICAN' : 'blue'}
I want to add another key: 'ITALIAN' : 'orange'
How do I append this to 'groups'?
Dictionary items have no implicit sequence, so you don't "append" to
one.
Assigning any value to a key in the dictionary will create that key if
it doesn't exist.
groups = {'IRISH': 'green', 'AMERICAN': 'blue'}
groups['ITALIAN'] = 'orange'
print groups
{'IRISH': 'green', 'AMERICAN': 'blue', 'ITALIAN': 'orange'}
Please enjoy your trip through the Python tutorial, working through
the examples and understanding each one.
<URL:http://docs.python.org/tut/>
--
\ "It is the responsibility of intellectuals to tell the truth |
`\ and expose lies." -- Noam Chomsky |
_o__) |
Ben Finney