Hunters and Prey python

Hey guys, i’m getting an error when I try to run the following code. I get “Error assigning to rvalue” please help.

def pickUpCoin():
    coin = hero.findNearest(hero.findItems())
    if coin:
def summontroops():
    if < hero.costOf("soldier"):
def commandSoldier(soldier):
    enemy = soldier.findNearest(soldier.findEnemies())
    if < 50:
        hero.command(soldier, "move", {"x": 11, "y": 50})
elif enemy:
    hero.command(soldier, "attack", enemy)
def commandArcher(soldier):
    enemy = soldier.findNearest(soldier.findEnemies())
    hero.command(soldier, "move", soldier.pos)
    if enemy:
        if soldier.distanceTo(enemy) < 25:
            hero.command(soldier, "attack", enemy)
while true:
    friends = hero.findFriends()
    i = 0
    for i < len(friends):
        friend = friends[i]
        if friend.type == "soldier":
        elif friend.type =="archer":
        i += 1

Couple problems:

  • true should be True
  • In the commandSoldier function, the elif block is not indented properly.
  • for i < len(friends): should be while i < len(friends): (this is where your error comes from)
  • if < hero.costOf("soldier"): should be >= instead of <

i wish i could help you