Help on Ogre-Encampment (backwoods forest)

currently my code is

loop:
    enemy = self.findNearestEnemy()
   if self.findNearestEnemy()
   self.attack(enemy)
   if else self.attack(Chest)

but when the enemys come upto me, my player just sits there, doesnt attack the chest or enemys, just stands there and dies

Please format your code according to the FAQ

Hey there, what language are you using?
I’m not sure, but it seems to me that it should be else if on line 5, or possibly elif.
Also, to format the code, you can highlight it and then push the </> button.
Hope I helped!

As people have said before, format your code properly. I’ve done it for you this time, but do so yourself in the future.

I’ll go through your code step by step:

Line 3: You need to check for enemy, since you already created a variable for findNearestEnemy(). Also, if-statements require a colon after the statement is asked.

Line 5: You only need an else, not an if else. Again with the colon.

Overall comment: Your indentations are a little mixed up. You need to indent your code inside the loop all the same level, then indent one more for if and else blocks.

I have no idea what the “</>” button is.
and i’m using python

oh… I thought you meant in the actual level.
I managed to get past it, thanks!