I can’t find that level in the list. What is the actual name of this level? This will help us make sure we are matching the instructions and be able to test the code.
One thing I did notice, you don’t need to reassign the enemy variable if you use elif instead of a second if. By doing this, you may be counteracting your first if.
enemy = hero.findNearestEnemy()
if enemy.pos.y > hero.pos.y:
hero.moveXY(hero.pos.x, hero.pos.y + 4)
enemy = hero.findNearestEnemy() # remove this
if enemy.pos.y < hero.pos.y: # change to elif
hero.moveXY(hero.pos.x, hero.pos.y - 4)