[SOLVED]How to kill monsters that has array("Hit and freeze")


Hi, there
I have read this forum https://discourse.codecombat.com/t/solved-hit-and-freeze-help/14115/21
I have written code below, however hero cannot kill monsters that has array.
Alert says “distanceTo’s argument target should have type object, but got array. Find the distance to target unit”

# You are trapped. Don't move, it'll be painful.

# This function checks if the enemy is in your attack range.
def inAttackRange(enemy):
    distance = hero.distanceTo(enemy)
    # Almost all swords have attack range of 3.
    if distance <= 3:
        return True
        return False

# Attack ogres only when they're within reach.
while True:
    # Find the nearest enemy and store it in a variable.
    enemy = hero.findEnemies()
    # Call inAttackRange(enemy), with the enemy as the argument
    # and save the result in the variable canAttack.
    canAttack = inAttackRange(enemy)
    # If the result stored in canAttack is True, then attack!
    if canAttack == True:

Could you kindly tell me hints?


I have stored array here. It ought to store single object.


Sorry in a rush but does findEnemies work?

Reading I thought it was trying to say hero.findNearestEnemy()