Hi all,

How to access the value of WER from the following:

valuesfor1 = [('WER', 100)]
valuesfor2=  [('WER', 700)]

My requirement is I need to compare WER from valuesfor1 with WER from valuesfor2.
ie something like

if [('WER', 100)] < [('WER', 700)] :
                         print "values for 2 is greater"
                        #statements follow

How to do this?

Regards,
Prashanth

Recommended Answers

All 2 Replies

Give this a try, using [ ] to index in that tuple.

valuesfor1 = [('WER', 100)]
valuesfor2=  [('WER', 700)]

for tuple1 in valuesfor1:
    for tuple2 in valuesfor2:
        if tuple1[0] == tuple2[0]:
            if tuple1[1] < tuple2[1]:
                print "values for 2 is greater"
            elif tuple1[1] > tuple2[1]:
                print "values for 1 is greater"
            else:
                print "values are the same"

This works directly as you wrote, if the length of tupple is 1 and contains only 1 two-tupple with same 0-elment

>>> if [('WER', 100)] < [('WER', 700)] :
                         print "values for 2 is greater"
                        #statements follow

                         
values for 2 is greater
>>>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.