Zoo Keeper Python Help


My hero summons the four soldiers and they move to the points but they dont attack and the ogres then kill one and attack the crate and then the yeti is summoned also i want to summon more than four soldiers so that i have more men to defend the crate so how do i do that heres my code

points = []
points[0] = {"x": 33, "y": 42}
points[1] = {"x": 47, "y": 42}
points[2] = {"x": 33, "y": 26}
points[3] = {"x": 47, "y": 26}

while self.gold <=80:
    coin = self.findNearest(self.findItems())
    if coin:
for i in range(4):

    friends = self.findFriends()
    for j in range(len(friends)):
        point = points[j]
        friend = friends[j]
        enemy =  friend.findNearestEnemy()
        if enemy and enemy.team == "ogres" and friend.distanceTo(enemy) < 5:
            self.command(friend, "attack", enemy)
        if friend:
            self.command(friend, "move", point)


When you run your code, your code will command your friends to atack an eneny that meets the requirements. However, you then check for a friend. If there is, theb that friend will move to the point, overriding the attack command. Don’t use a separate if-statement; just use an else-block.


thanks i beat it next level


Can You plz tell me how to do that since I am new.(Python)@lundor5


See the other zookeeper thread. It discusses exactly this error:


i beat it weeks ago i changed to an else after the if enemy