I think I mayyy understand what you’re getting at…?
In plain language, the a)
while enemies: should translate to “as long as their are enemies” (as long as the
enemies array isn’t
None), execute the following code. So I thought, the first loop should be skipped as soon as there aren’t any enemies left (
The reason why I thought this could work was that it also works with
if also takes an object (I don’t know if that object can be an array though)!
#do the following things:...
(which IMO is stupid btw - short and handy, but illogical)
enemy is the result of
hero.findNearestEnemy. If it returns
None, then the
if-statement evaluates to false and the ensuing code is skipped.
My reasoning was like this: isn’t
while logically much the same as
if? The only difference is that
while keeps checking the condition repeatedly,
if does it only once. So I thought
while should accept the same arguments as
enemies is the result of
hero.findEnemies returns an empty array, the
while enemies: condition evaluates to false, and the ensuing code is skipped.
I’m gonna make another hypothesis:
if do accept the same arguments, meaning both do accept objects, but only of type integer, float or string: it can’t be an array.
if this hypothesis is correct, then the type error should still definitely regard the line
while enemies: (line 9), it clearly has nothing to do with line 12!
Conclusion: That error message is stupid. It doesn’t make sense. I’m at square one (while having reached further stages of a side quest). @xython, your answer is actually also referring to that side quest and isn’t dealing with this erroneous error message, I think?
Who can we ask whether or not my hypothesis is correct?