I'm pretty new to Python, so maybe this is a very stupid question but I can't find the fault.
I have the following code, which runs when the script is started (on an Raspberry Zero W). The convertTimeToArray() function returns always an array, but not always an filled array. That is correct. So I need a check if that array is filled and if yes then that array needs to be handled (show on a ledstrip in this case).
try:
while True:
array = convertTimeToArray(strip)
print('len(array)', len(array))
print('array and len(array) > 0', array and len(array) > 0)
if array and len(array) > 0 is True:
showArray(strip, CLOCK_COLOR,array, EFFECT)
print('array set, now waiting 50 seconds')
time.sleep(50)
else:
print('wait another 5 seconds')
time.sleep(5)
except KeyboardInterrupt:
colorWipe(strip, Color(0, 0, 0), 1)
But, the code is always directed to the else of this block even if the statements are true (in the console):
len(array) 20
array and len(array) > 0 True
wait another 5 seconds
What I'm doing wrong here? I double checked the tabs, and I'm pretty sure that they are correct.
Aucun commentaire:
Enregistrer un commentaire