Hi;

On 24/02/2011 9:35 PM, sunil tech wrote:
Hi all...

i have d=[{'qty':0.0},{'qty':0.0}]

If there isn't some pressing reason to dictionaries as the list items (but since I'm not sure how you're generating the list/what you are later using the list I can't tell ofc but if applicable to your situation I'd suggest just doing for creation of the list
 d = []
(logic for whatever gives your values)
d.append(value)
etc.)
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...

Thank you in advance
Presuming you do have to use the dictionaries:
qty = 0.0
for item in d:
    for subitem in d:
        if item[subitem] != 0.0:
            qty = item[subitem]
            break
if qty != 0.0:
    print "some message - for example a non zero qty = %f" % qty

(presuming you are using Python 2x - if using python 3x the syntax will be slightly different) Hopefully that will serve your purpose if not just post again and I or one of the more frequently posting helpful users here will answer soon.
Nick

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to