Holding until next value change

andrzej.brozi at gmail.com andrzej.brozi at gmail.com
Sat Aug 20 10:18:24 EDT 2016


Hello

Perhaps this would suffice:

prev = None
for value in main_call():
    if value==prev:
        pass
    else:
        prev = value
        if prev>0:
            print('+v')
        elif prev<0:
            print('-v')
        else:
            print('0')

Of course this will work only if subsequent values are exactly the same.
If not - then "value==prev" should be replaced by some other test (for sign or for proximity).

Regards
Andrzej Brozi



More information about the Python-list mailing list