Help for : 5 ème level of 2nd World ("Emboutisseur de Patrouille")


I need your help for “Embatisseur de Patrouille” (french version) the 5ème lvel of the 2nd world (the forest).
My hero survive, but the code isn’t good, and I don’t understand why.

I type :

    enemy = self.findNearestEnemy()
    # S'il un ennemi existe, alors attaque le !!
    if enemy
    if not enemy

the goal of the level is to attack the enemy if they are here, and not attack (or do anything? I make my hero move right here) is no enemy is here.
Can you help me?


Hello, Essai, and welcome. Please read the FAQ prior to your next post, in order to learn how to format your code properly. I’ve done it for you this time, but learn how to do so yourself in the future.

The thing about Python is that indentations are important. Like a loop, you must put one indentation before things inside an if-statement, like this:

if enemy:

Also, your if-statements must have a colon in front of them, in order to be recognized as such.


Like this ? :

# Souviens toi qu'un ennemi peut ne pas exister pour le moment.
    enemy = self.findNearestEnemy()
    # S'il un ennemi existe, alors attaque le !!
    if enemy:

I thank you for answer to my question so fast, and i beg your pardon for not see the FAQ post of the forum (and I think a copy/paste from the game make the deal right).
But I think you’re not see what my problem is.

The problem is I suceed in killing the monsters (my hero do it, and in the game they’re no problem it’s work with or without " : ", , they’re neither a problem of spaces because my hero suceed in killing monsters) but i have a problem of “code propre” (“proper code”?).

I need to make my hero 'not attacking" while there no monsters (if I understand well) and I see the in game guide(in english even if french is my mother tongue), and I don’t understand why my code isn’t “propre”.(unexpected token).

The problem is I haven’t a clue, for know how to make my hero do nothing.Or for typing right the fact that there no enemy.
That’s why, I make my hero move right if there no enemy(or what I thinked I will do).

Thank again for your dedication and speed of answer. -Essai1


In your code example, your self.attack(enemy) still needs to be indented one more level.

Your code does work, yes. However, it’s the fact that the syntax of your code is not correct that causes the “Unexpected token” error.

You do not need to specifically tell your hero not to attack when there are no ogres. They should just stop on their own.


Thanks a million! It’s works!