/level/bookkeeper


#1

I was stuck here / and it did not work
defeated = 0
while True:
enemy = hero.findNearestEnemy()
if enemy:
hero.attack(enemy)
if enemy.health <= 0:
defeated += 1
if hero.time > 15:
break

Tell Naria how many enemies you defeated.

hero.moveXY(59, 33)
hero.say(defeated)

Collect coins until the clock reaches 30 seconds.

while True:
coin=hero.findNearestItem()
if coin:
hero.moveXY(coin.pos.x,coin.pos.y)
coinsCollected = hero.gold ()
if hero.time >30:
break

hero.moveXY(59,33)
hero.say(“Hi Naria, I collected " + gold + " gold!”)

Fight enemies until the clock reaches 45 seconds.

Remember to reset the count of defeated enemies!

defeated=0
while True:
enemy=hero.findNearestEnemy()
if enemy:
hero.attack(enemy)
if health <=0:
defeated +=1
if time >45:
break
hero.moveXY(59,33)
hero.say(defeated)

Tell Naria how many enemies you defeated.


#2

I formatted your code and wrote some comments that should help you find the error.

# Collect coins until the clock reaches 30 seconds.
while True:
    coin=hero.findNearestItem()
    if coin:
        hero.moveXY(coin.pos.x,coin.pos.y)

# There are two things to think about in the next line of code:
# 1. Pay attention to the variable you declare. Are you going to use it later?
# 2. hero.gold() does not exist, but hero.gold WITHOUT the parentheses exists. Refer to the picture below this code (click 'Picture of hero.gold in the API' to show).
    coinsCollected = hero.gold ()

    if hero.time >30:
        break

hero.moveXY(59,33)

# You haven't declared the variable 'gold' anywhere:
hero.say(“Hi Naria, I collected " + gold + " gold!”)
Picture of hero.gold in the API

Screenshot (37)_LI