Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Define inAttackRange - Problem Solved

#1

Hi, could you please help me have a look that why my code is wrong? I was trying to define the inAttackRange.

Thanks a lot in advance for your help and look forward to your reply!

#2

Try doing

def inAttackRange(enemy):
    enemy=hero.findNearestEnemy()
    if enemy:
        if help.distanceTo(enemy)<=3
            return True
        else:
            return False
#5

Note: Don’t post working code.

1 Like
#6

I was trying to help others who might face the same problem as me. And can you please explain what do you mean by don’t posting working code?

#7

It means do not post codes that can be used to successfully complete a level.

#8

If you are unsure about something, try reading the FAQ.
https://discourse.codecombat.com/faq