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

Short-Sighted Burl - Python

I don’t know whats wrong, someone pls help.

# Collect coins and run, or else the burl will find you.

# This function allows your hero take an item.
def takeItem(item):
    hero.moveXY(item.pos.x, item.pos.y)


# Write the function "checkTakeRun" with one parameter.
# If the item exists, use "takeItem" function to take it.
# Go back to the start (green mark), with or without the item.
def checkTakeRun(coin):
    if coin:
        takeItem()
        hero.moveXY(40, 12)

# Don't change this code.
while True:
    hero.moveXY(16, 56)
    coin = hero.findNearestItem()
    checkTakeRun(coin)
    hero.moveXY(64, 56)
    coin = hero.findNearestItem()
    checkTakeRun(coin)

There are 2 issues with:

def checkTakeRun(coin):
    if coin:
        takeItem()
        hero.moveXY(40, 12)

You are calling takeItem, but haven’t told it what to take. And, you want the hero to return to the green X, whether or not there is a coin…right now, you only have him return when there is a coin.

1 Like

Thank you, I was able to solve it.