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

Help with backwoods fork

i have already solved this one now but thanks

can any body help me

1 Like

Hi Ritic-the-Cold,

Welcome to the forum. We’d be happy to help you!

Can you post your current code, and a bit of a description about what is/isn’t happening when you run it.

There’s instructions on how to format your code here.

Jenny

1 Like

this is my code
def checkAndAttack(target):
# The ‘target’ parameter is just a variable!
# It contains the argument when the function was called.
if target:
enemy = hero.findNearestEnemy()
hero.attack(target)
hero.moveXY(43, 34)

while True:
hero.moveXY(58, 52)
topEnemy = hero.findNearestEnemy()
# Using the checkAndAttack function with the topEnemy variable.
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(topEnemy)

Hi @Ritic-the-Cold, your code still isn’t formatted. Meaning it doesn’t show the indentation (how far the lines are pushed in). I can see a problem however:

At the top x you attacked the top enemy, now you’re at the bottom x you should attack the bottom enemy. (you’ve got a variable for that!).
It could be an indentation problem however so please put three ``` on two lines, then make a space inbetween them and post your code directly from codecombat. If you just post it from your post it still won’t be formatted.
Thanks
Danny