Level Mountain mercenaries error

Hello!

I have this error in python solution:
Error Cannot read property ‘start’ of undefined

This is my code on this level:

def bestValue(item):
    return item.value / hero.distanceTo(pet.fetch(item)

def findGoodItem(items):
    g_item = items[0]
    for item in items:
        if BestValue(item)>BestValue(g_item):
            g_item = item
    return g_item


while True:
    item = findGoodItem(hero.findItems())
    hero.move(item)

    if hero.gold > hero.costOf("soldier"):
        hero.summon("soldier")

    enemy = hero.findNearest(hero.findEnemies())
    if enemy:
        soldiers = hero.findFriends()
        for soldier in soldiers:
            hero.command(soldier, "attack", enemy

        while enemy.health>0:
            hero.attack(enemy)

return item.value / hero.distanceTo(pet.fetch(item)
odd number of brackets?

1 Like

Thank you, It’s help!)

(Solution removed)

New code!

Please do not post working code/solutions. The purpose of this board is to help people learn and simply providing/posting completed solutions is counterproductive to that goal. Thank you.

1 Like