What is the best way to append and clear the list deriv_position = []
from inside the function test
?
I got NameError: name 'deriv_position' is not defined
class TestClass:
deriv_position = []
def test():
if len(deriv_position) > 0:
print("trade is open")
deriv_position.clear()
else:
print("trade is close")
deriv_position.append("1")
test()