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

[SOLVED] Need help on level 14 Computer science 3

# Don't attack the burls!
# Functions can return a value.
# When a function is called, it will be equal to the value the function returns.

def shouldAttack(target):
    # return False if no `target`
    return False if:
        target.type == n/a
    # return False if target.type == "burl"
    return False if:
        target.type == "burl"
    # Otherwise, return True
    return True

while True:
    enemy = hero.findNearestEnemy()
    # Here we use shouldAttack() to decide if we should attack!
    # heroShouldAttack will be assigned the same value that shouldAttack() returns!
    heroShouldAttack = shouldAttack(enemy)
    if heroShouldAttack:
        hero.attack(enemy)

The only error I get is “There is a problem with your code.”

I ended up solving! thanks!