Enemy = Null, filter confusingly functioning (Solved)

When I run:

enemies = hero.findEnemies()
if enemies:

The result is Hero saying “Enemies” when there are no enemies. Why does the if enemies not filter?
if I run:

enemies = hero.findEnemies()
if enemies:
    for enemy in enemies:

Then my Hero says the names when there are actually enemies. Any Ideas?

What is hero.findEnemy ?

If you wanted to write hero.findEnemies, then without brackets it’s a function.

bool(function) is True
1 Like

Oh, that was a typo in my post, not code.

Got it. There is a problem with python interpretator and it works like in JS.
So the empty array is true in conditionals.
Try to check
if enemies.length:


Thank you! This issue has been plaguing me :slight_smile: