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

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by pyTony

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
>>>``````