I’m learning on python. So Ive done all that the code asked but I get an error saying that a value is not defined even though a previous function that is there by default should have defined it. here is my code “**” this will represent where the error is. here is also the link: CodeCombat - Coding games to learn Python and JavaScript?

```
def findSoldierOffset(soldiers, i):
soldier = soldiers[i]
angle = i * 360 / len(soldiers)
return radialToCartesian(5, angle)
# This function does the math to determine the offset a soldier should stand at.
def radialToCartesian(radius, degrees):
radians = Math.PI / 180 * degrees
xOffset = radius * Math.cos(radians)
yOffset = radius * Math.sin(radians)
return {"x": xOffset, "y": yOffset}
peasant = hero.findByType("peasant")[0]
soldiers = hero.findByType("soldier")
# Use findByType to get an array of your soldiers.
while True:
# Use a for-loop to iterate over range(len(soldiers)).
for index in range(len(soldiers)):
# Find the offset for a soldier.
findSoldierOffset(soldiers, index)
# Add the offset.x and offset.y to the peasant's pos.x and pos.y.
newX = xOffset + peasant.pos.x
newY = yOffset + peasant.pos.y
# Command the soldier to move to the new offset position.
hero.command(soldiers[index], "move", {"x": newX, "y": newY})
# The hero should keep pace with the peasant!
hero.move({"x": hero.pos.x + 0.2, "y": hero.pos.y})
```

not sure what I’m doing wrong but I’m eager to find out.