A fine mint : Out of time

Hello everyone,

Been trying to hack at this problem for a while now…
Can anyone guide me what I am missing? Answer doesn’t have to be overt, but this is driving me Ape…

Peons are trying to steal your coins!

Write a function to squash them before they can take your coins.

def pickUpCoin():
----coin = hero.findNearestItem()
if coin:
----hero.moveXY(coin.pos.x, coin.pos.y)

Write the attackEnemy function below.

Find the nearest enemy and attack them if they exist!

def attackEnemy():
enemy = hero.findNearestEnemy()
if enemy:
hero.attack(enemy)

while True:
attackEnemy() # ∆ Uncomment this line after you write an attackEnemy function.
pickUpCoin() "

I took a look at your code and it seems to work fine.

I worry that the indentation may be broken, so if you can wrap your code snippet in 3 backticks ( ` ) at the start and at the end of your code, it’ll format it better.

1 Like

Turns out I had to use a Range type, makes sense. My code was correct anyhow.

Thank you for your suggestion anyway! :stuck_out_tongue:

def pickUpCoin():
item = hero.findNearestItem()
def attackEnemy():
enemy = hero.findNearestEnemy()
if enemy:
hero.attack(enemy)

while True:
attackEnemy()
pickUpCoin()
this is my code and its onely attacks the enemys not colect the coins