# Define the function: pickUpNearestCoin
friends = hero.findByType("peasant", hero.findFriends())
for friends in friends:
enemy = friend.findNearestEnemy()
if enemy:
hero.command(friend, "attack", enemy)
peasant = hero.findByType("peasant")[0]
This part of yours is not what the blue text says. You should replace it with this and define the function PickUpNearestCoin
# Define the function: pickUpNearestCoin
def pickUpNearestCoin():
items = hero.findItems()
nearestCoin = hero.findNearest(items)
if nearestCoin:
hero.move(nearestCoin.pos)