HELP! Simple question re: dictionaries
chibaA at TinterlogD.Tcom
chibaA at TinterlogD.Tcom
Wed May 10 15:49:17 EDT 2000
I'll give it a shot - thanks!
kc
On 10 May 2000 20:34:09 +0100, Michael Hudson <mwh21 at cam.ac.uk> wrote:
>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