How does it work?

I got a bizarre case inside my function.
So, I have a variable that is equal to 2000 by default. There are no places where I set the value.
ue_projspd1_2
And here are two variants of the function. For the short intro, I set a new value at the end


For some reason, my variable changes from 2000 to a new value before
ue_projspd1_v1
But if I set the value right before the first print string it works as I expected
ue_projspd1_v2

Your variable is not a function variable. Its a global variable so when it runs first time it will store the value (1794 or something) but when you run the function again last value is there.

In the second case you initialize the variable at the beginning of the function so it will be always 2000 and then you put a different value there so the logic that is running here is right

1 Like

Oh, you’re right. Thanks a lot

1 Like