# 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:
self.move(coin.pos)
for i in range(4):
self.summon("soldier")

loop:
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

I NEED HELP it says there an error with that I can’t move to point.pos

# Put a soldier at each X.

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}

# 1. Collect 80 gold.

while True:
coin = hero.findNearest(hero.findItems())
if hero.gold <=80:
if coin:
hero.move(coin.pos)

# 2. Build 4 soldiers.

for i in range(4):
hero.summon(“soldier”)

# 3. Send your soldiers into position.

while True:
friends = hero.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:
# Command friend to attack.
hero.command(friend, “attack”, enemy)
pass
else:
hero.command(friend, “move”, point.pos)
# Command friend to move to point.
pass

Hello! I would like to ask do you still need help with passing the level, or you already passed it??

Already passed it thank you, I could use help with Pender’s Trial.

Hi and welcome to the forum!
@sunshin3crow, I’m so sorry we never even posted on here. But I’m glad you fixed it!