Iterating over the data items in a dict.

Gaute B Strokkenes gs234 at cam.ac.uk
Tue Nov 7 12:35:44 EST 2000


Dale Strickland-Clark <dale at out-think.NOSPAMco.uk> writes:

> 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()

Thanks!  It's just what I was looking for.

-- 
Big Gaute                               http://www.srcf.ucam.org/~gs234/
They collapsed....  like nuns in the street...
 they had no teen appeal!



More information about the Python-list mailing list