Iterating over the data items in a dict.

Dale Strickland-Clark dale at out-think.NOSPAMco.uk
Mon Nov 6 09:15:05 EST 2000


Gaute B Strokkenes <gs234 at cam.ac.uk> wrote:

>
>I would like to iterate over the data items, not the keys, in a dict.
>The closest I can get is:
>
>        for n in mydict.keys():
>            i = mydict[n]
>            do_something_useful(i)
>
>However, this seems a bit awkward.

Use mydict.values()


--
Dale Strickland-Clark
Out-Think Ltd
Business Technology Consultants





More information about the Python-list mailing list