Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Level: The Agrippa Defense B


What’s wrong with the code?

def enemyInRange(enemy):
    # Return true if the enemy is less than 5 units away.
    if enemy < 5:
        return True

def cleaveOrAttack(enemy):
    if hero.isReady('cleave'):

while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        # Check the distance of the enemy by calling enemyInRange.
        if enemyInRange(enemy):


I don’t see what you Returned True for. Do something with the True perhaps?


You forgot to check enemy’s distance when defining the function enemyInRange() :wink:


you use true when it says “while True: …”


question is then is how do you fix it?


The problem is with if enemy < 5 : it’s meaningless this way. It should be if hero.distanceTo(enemy)