Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

[SOLVED]If anyone can please help

So I am having issues with it stopping in my code and need someone to look over my code and see what did wrong. Can anyone help?

 #Commented out to stop infinite loop.

# Kill at least 6 ogres on the left side.
# Then, collect at least 30 gold on the right.
# This variable is used for counting ogres.
defeatedOgres = 0;

# This loop is executed while "defeatedOgres" is less than 6.
while defeatedOgres < 6:
    enemy = hero.findNearestEnemy()
    if enemy:
        hero.attack(enemy)
        defeatedOgres += 1
    else:
        hero.say("Ogres!")

# Move to the right part of the map.
hero.moveXY(49, 36)

# This loop is executed while you have less than 30 gold.
while hero.gold < 30:
    # Find and collect coins.
    item = hero.findNearest(hero.findItems())
    if item:
        hero.move(item.pos)
    
# Move to the exit.
hero.moveXY(76, 32)

What level is this?
Lydia
(In the future, please tell the level. If you have solved it, please delete your code if it runs and successeds so others don’t try and cheat)

2 Likes

Okay thanks for that