Help with Backwoods Forest[SOLVED]

cannot figure out why my code is incorrect

# Use the checkAndAttack function to make your code easy to read.

# This function has a parameter.
# An parameter is a way of passing information into a function.
def checkAndAttack(target):
    # The 'target' parameter is just a variable!
    # It contains the argument when the function was called.
    if target:
        hero.attack(target)
    hero.moveXY(43, 34)

enemy = hero.findNearestEnemy()
checkAndAttack(enemy)

while True:
    hero.moveXY(58, 52)
    topEnemy = hero.findNearestEnemy()
    checkAndAttack(topEnemy) 
    # Move to the bottom X mark.
    hero.moveXY(58, 16)
    # Create a variable named bottomEnemy and find the nearest enemy.
    bottomEnemy = hero.findNearestEnemy()
    # Use the checkAndAttack function, and include the bottomEnemy variable.
    checkAndAttack(bottomEnemy)

Welcome to the forum!! What level is this?

Thanks Eric! This is Backwoods Fork under Backwoods Forest https://codecombat.com/play/level/backwoods-fork

delete this, It SHOuld work

Hi elemersglue,

Your code works fine for me. Are you getting an error message, or is the hero not succeeding? Can you take a screenshot of you equipment and post it here?

Jenny

deleted it and no luck :frowning:

I think jka might be right I think it is a equipment issue you might need more health but I dont think so.

hi there! this is the error i’m getting :slight_smile:

yeah its totally a equipment issue.

you don’t have a sword powerfull anoghf to one shoot the munchkins and because of that your hero attacks the munchkin once then proceeds to move to the next X so maybe make your hero attach two times before moving to the next X

1 Like

thank you! i adjusted my equipment and it works now omg thank you SO much

thanks a milllion!!!

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.