OrderedDict - For Loop - Delete current iterated value?

Viewed 25

I need to compare current iteration of an OrderedDict's value with the previous iteration and then remove that current iteration if it is smaller than the previous. But when I use int() to do so, it returns ValueError: invalid literal for int() with base 10: ''.

How do I make it so that it evaluates the two values as integers and remove that key:value item in the OrderedDict if it is smaller than the previous iteration?

for key, value in OrderedDict(left_score_dict).items():
        if int(value) < int(value)-1:
            del left_score_dict[key]

Is there some kind of dictionary comprehension that can used here to convert the OrderedDict's values to integers, either temporary in the expression or permanently?

Thank you!

P.S.: Quite the beginner over here.

0 Answers
Related