I need help on the level Oasis

I need help on the level Oasis. Here is my code:

loop:
    x = self.pos.x
    y = self.pos.y
    enemy = self.findNearestEnemy()
    if enemy and self.distanceTo(enemy) < 10:
        # Move to the left by subtracting 10 from your X coordinate.
        x = x - 10
        
    else:
        # Move to the right by adding 10 to your X coordinate.
        x = x + 10
        self.moveXY(x, y). 

here is the link:

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

Move the command where you actually move your hero outside th else-block. That should solve your problem.