# /level/bookkeeper

**URL:** <https://discourse.codecombat.com/t/level-bookkeeper/12195>\
**Category:** Uncategorized\
**Created:** [August 17, 2017, 4:31am UTC](https://discourse.codecombat.com/t/level-bookkeeper/12195 "2017-08-17T04:31:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vinhvi\_n\_Co\_Xa\_Khong](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/vinhvi_n_co_xa_khong/32/6487_2.png) [@Vinhvi\_n\_Co\_Xa\_Khong](https://discourse.codecombat.com/u/Vinhvi_n_Co_Xa_Khong)\
**Post date:** [August 17, 2017, 4:31am UTC](https://discourse.codecombat.com/t/level-bookkeeper/12195/1 "2017-08-17T04:31:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![byobcello](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/byobcello/32/6684_2.png) [@byobcello](https://discourse.codecombat.com/u/byobcello)\
**Post date:** [August 17, 2017, 6:18am UTC](https://discourse.codecombat.com/t/level-bookkeeper/12195/2 "2017-08-17T06:18:35Z")

</div>

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

```python
# 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](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex016/uploads/codecombat/original/2X/2/21e6289456cb54a543d74ba6190467d818bdd951.jpg)
