looping through the keys of a dictionary

Burkhard Kloss bk at xk7.com
Tue Aug 21 11:14:50 EDT 2001


> Is there a way to loop through the keys of a dictionary (whitout using
> a list containing all those keys)?
>
> e.g. mydict = {'123':[1,9,13],'125':[6,8],'225':[5]}
for key in mydict.keys():
    print key, mydict [key]

should do the trick





More information about the Python-list mailing list