Dictionary -> List/Array

15 views
Skip to first unread message

Tarek Amr

unread,
Jan 13, 2006, 9:59:22 PM1/13/06
to pyth...@googlegroups.com
There are various data types in python, one of them is the dictionary which is some how similar to a hash table where you acceess the different entries there by their keys.

For example if we have
>>> d = {"a":"Ali","b":"Robert","c":"Cinthya"}
>>> d["a"]
Ali
>>>d["c"]
Cinthya

Suppose now we want to access these items as if they are in a normal array (d[0],d[1],etc) how can we do that ?
>>> d[d.keys()[0]]
Ali
>>> d[d.keys()[1]]
Robert

etc.
--
Best Regards,
Tarek Amr
Reply all
Reply to author
Forward
0 new messages