The Final Kithmaze help

##statements ≠ lines


Remove the :one:s from the brackets, because they count as separate statements.

Cheers

1 Like

Ah I see I didn’t know that was the case. Thank you very much! :smiley:

1 Like

your first response worked perfectly. I’m not sure what the significance of this is yet:

while (this.findNearestEnemy() !== null)
this.attack(this.findNearestEnemy());

I guess I’m just too new to the language.

1 Like

I cannot finish the level. I have done the right code based on all the comments and it doesn’t allow them to go through the door. I am using js.

Am I missing something?

1 Like

This level is still not working in js. Am I missing something

1 Like

Please include your code properly formatted inside of three backticks (`) before and after the code.

1 Like

Forgot to indent.
*This is Python.:wink:

1 Like

It comes up with a problem with the second code but the rest is all good

1 Like

Please remember to format your code according to the FAQ. As I have explained at various times to other users, it helps us understand the code a little easier. Thanks!

(If you find this helpful, please :heart: this post)

2 Likes

Thanks Dude! Helped me so much!!!

1 Like

Here’s my code
while True:
hero.moveRight()
hero.moveUp()
hero.moveRight()
enemy = hero.findNearestEnemy()
hero.attack(enemy)
hero.attack(enemy)
hero.moveDown(2)
hero.moveUp(1)

1 Like

Please format your code according to the FAQ. It helps understand your code better. It basically helps us help you! :smile:

Also, could you give some information on what is going wrong, what the game is saying etc.

Cheers! :beers:

(Please :heart: this post if it helps!)

3 Likes

sorry I replied so late guys

1 Like

[redacted, please don’t post solutions]

I used this and it worked

1 Like

won’t work… I have to use hero.move instead of self.move

1 Like

You are the best thanks for the help

2 Likes

It worked thanks!!!

2 Likes

Hey. I am doing LUA and I can’t get pass this level.

1 Like

I’ve been trying to figure out how to do this for like 10 minutes, and I can’t seem to figure out how. I’m using Javascript. Here’s my code:

var enemy = hero.findNearestEnemy();

while (true) {
     hero.moveRight();
     hero.moveUp();
     hero.moveRight();
     hero.moveDown(2);
     hero.moveUp();
     hero.enemy;
     hero.attack(enemy);
     hero.attack(enemy);
}

I’ve tried sticking this part in all the different spots I can think of, but it always runs the code early, and it says that there isn’t an enemy in my line of sight.

     hero.enemy;
     hero.attack(enemy);
     hero.attack(enemy);

Am I doing something wrong, or is the game bugging out?

1 Like

Please format your code according to the FAQ. It makes it easier to understand your code.
your are missing I think if enemy in that.
https://discourse.codecombat.com/faq

1 Like