Question:
in my code the function
result = client.get_active_orders('ETH-BTC')['SELL']
print(result)
produces an empty list []
.
It can also display a non-empty list if there are active orders.
The question is: how, using if
, to tell further code to be executed when the list is empty?
I try:
result = client.get_active_orders('ETH-BTC')['SELL']
if (result) == False:
print(result)
using print
I check to see if the code will be executed further. In my opinion "[]"
should be printed. But nothing is printed. So my if
block is wrong?
Answer:
An empty list cannot be false.
Try like this
if not result:
print(True)