[Tutor] dictionary values in strings

William O'Higgins william.ohiggins at utoronto.ca
Thu May 19 21:49:53 CEST 2005


I am trying to discover the syntax for call on a dictionary of lists by
key and index.

The data structure looks like this:

dol = {'key1':['li1','li2','li3'],'key2':['li1','li2','li3'],\
'key3':['li1'li2,'li3','']}

The keys are passed to a function as arguments, and I want the value of
the specified list index.  This is what I *thought* it would look like:

dol.key(argument)[0] # would return li1 when argument equals key1

But that's wrong.  The error I get is this:
AttributeError: 'dict' object has no attribute 'key'

I don't know how to interpret that error (well, I know I screwed up, but
... :-)  Thanks.
-- 

yours,

William

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.python.org/pipermail/tutor/attachments/20050519/78cdba4f/attachment.pgp


More information about the Tutor mailing list