Gh python save only previous variable and compare

Hi all,

I’m still very new to python and was wondering if there’s a quick way to be able to check whether the latest variable is greater or smaller than the previous input.

I am trying to animate increasing or decreasing arrows in gh as part of a visualisation which I was assuming could be done by using python to input true or false.


How about this:
EDIT : This is what you asked for

if 'previous' not in locals():
    previous = float('-inf')

if x > previous:
    a = True
    a = False

previous = x

EDIT : not this !


if 'maximum' not in locals():
    maximum = float('-inf')

if x > maximum:
    maximum = x

a = maximum

I’m not by the computer so I can’t type any code.
But you can solve this by using sticky: