# [SOLVED] Computer Science 5: Ring Bearer (python)

i am having problems with my code, it does not work when i run it and it says “need an object” at the line i marked.
here is my code:

# The second argument ‘i’ is the index of the soldier (in soldiers) you want to find the position for.

def findSoldierOffset(soldiers, i):
soldier = soldiers[i]
angle = i * 360 / len(soldiers)

# This function does the math to determine the offset a soldier should stand at.

radians = Math.PI / 180 * degrees
return {“x”: xOffset, “y”: yOffset}

peasant = hero.findByType(“peasant”)[0]

# Use findByType to get an array of your soldiers.

while True:
# Use a for-loop to iterate over range(len(soldiers)).
# Use a for-loop to iterate over your array of soldiers.
soldiers = hero.findByType(“soldier”) #<------------- this is where i am having the problem
for i in len(soldiers):
soldier = soldiers[i]
offset = findSoldierOffset(soldiers, i)
offsetX = peasant.pos.x + offset.x
offsetY = peasant.pos.y + offset.y
position = {“x”: offsetY, “y”: offsetY}
hero.command(soldier, “move”, position)
# Find the offset for a soldier.
# Add the offset.x and offset.y to the peasant’s pos.x and pos.y.
# Command the soldier to move to the new offset position.
# The hero should keep pace with the peasant!
hero.move({“x”: hero.pos.x + 0.2, “y”: hero.pos.y})

Hi @cxctia and welcome to the forum!

Here, we format the code as it is described here.

So could you format it how it is described there so we can help?

I actually figured out how how to solve it, thank you for reminding me how to format my code!