[Tutor] list of dictionary
Alan Gauld
alan.gauld at btinternet.com
Fri Feb 25 10:07:22 CET 2011
"sunil tech" <sunil.techspk at gmail.com> wrote
>
> i have d=[{'qty':0.0},{'qty':0.0}]
>
> when all the qty is 0.0,
> i want to perform some print operation
> (only at once, after it checks everything in the list of dictionary
> 'd')...
>
> if its not 0.0,
> print some message...
Just so I'm clear on the requirement you want something
like:
isZero = True
for each dictionary in d
if dictionary[qty] is not 0.0
print some message
isZero = False
if isZero:
some print operation
If so that should be easily translated into Python?
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list