HELP! Simple question re: dictionaries
Michael Hudson
mwh21 at cam.ac.uk
Wed May 10 15:34:09 EDT 2000
chibaA at TinterlogD.Tcom writes:
> Hi,
>
> I just want to write a for statement to go through each element of a
> dictonary. I would have assumed it would look something like this
> (argumentList being the dictonary):
>
> for ___ in argumentList:
> # whatever...
>
> ... but I'm not sure of the exact syntax. If anyone knows, could you
> let me know? Thanks!
for key,value in argumentList.items():
# whatever ...
is pretty idiomatic...
Cheers,
M.
--
34. The string is a stark data structure and everywhere it is
passed there is much duplication of process. It is a perfect
vehicle for hiding information.
-- Alan Perlis, http://www.cs.yale.edu/~perlis-alan/quotes.html
More information about the Python-list
mailing list