# [SOLVED]Volcano Fighters help please

code

``````# Complete the paladin rectangle to protect the village.

# This function finds the left-most unit.
def findMostLeft(units):
if len(units) == 0:
return None
mostLeft = units
for unit in units:
if unit.pos.x < mostLeft.pos.x:
mostLeft = unit
return mostLeft

# This function finds the bottom-most unit:
def findMostBottom(units):
if len(units) == 0:
return None
mostBottom = units
for unit in units:
if unit.pos.y < mostBottom.pos.y:
mostBottom = unit
return mostBottom

# Find the top left paladin with findMostLeft function:
findMostLeft()
# Find the bottom right paladin with findMostBottom function:
findMostBottom()

# Use X coordinate from the top left paladin:
# and Y coordinate from the bottom right paladin:
x = findMostLeft.pos.x
y = findMostBottom.pos.y
# Move to the {X, Y} point from the previous step:
hero.move({x, y})
# Continue to shield while the volcano is erupting:
while True:
hero.shield()

``````

the error

Maybe define a variable for each of the paladins, so `mostLeft = findMostLeft(paladins)`?

Ok I will try that but where should I put it?

Here, add a variable with mostLeft and mostBottom. Then change `x = findMostLeft.pos.x` to `x = mostLeft.pos.x` and change `y = findMostBottom.pos.y` to `y = mostBottom.pos.y`.

didn’t work same error

``````# Complete the paladin rectangle to protect the village.

# This function finds the left-most unit.
def findMostLeft(units):
if len(units) == 0:
return None
mostLeft = units
for unit in units:
if unit.pos.x < mostLeft.pos.x:
mostLeft = unit
return mostLeft

# This function finds the bottom-most unit:
def findMostBottom(units):
if len(units) == 0:
return None
mostBottom = units
for unit in units:
if unit.pos.y < mostBottom.pos.y:
mostBottom = unit
return mostBottom

# Find the top left paladin with findMostLeft function:
# Find the bottom right paladin with findMostBottom function:

# Use X coordinate from the top left paladin:
# and Y coordinate from the bottom right paladin:
x = mostLeft.pos.x
y = mostBottom.pos.y
# Move to the {X, Y} point from the previous step:
hero.move({x, y})
# Continue to shield while the volcano is erupting:
while True:
hero.shield()

``````

I think this is the problem. In python the things with the {} are called sets. If you look at the correct usage with move:

``````hero.move({"x": 56, "y": 44})
``````

The x and the y are in brackets and the actual values go after them. So if your x and y variables are the values (like 56 and 44) where will you put them? You should have double xs and ys, two with brackets and two without.
Danny

1 Like

I didn’t catch that, but I think @Deadpool198 is right, that might be the issue, you could use a moveXY statement or a move statement.

1 Like

Thanks Deadpool and Abc!

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.