# Help on Dangerous Tracks (python)

so im trying to do this level but even though all of my code is pretty much right it won’t work? heelpp.

``````# Protect the village with fire traps.
# Mine all passages in four directions.
# You have 80 seconds before the ogres attack.

# Build traps on the line y=114 from x=40 to x=112 with step=24.
def buildNorthLine():
for x in range(40, 113, 24):
hero.buildXY("fire-trap", x, 114)

# Build traps on the line x=140 from y=110 to y=38 with step=18.
def buildEastLine():
# Complete this function:
for y in range(110, 39, 18):
hero.buildXY("fire-trap", 140, y)
pass

# Build traps on the line y=22 from x=132 to x=32 with step=20.
def buildSouthLine():
# Complete this function:
for x in range(132, 33, 20):
hero.buildXY("fire-trap", x, 22)
pass

# Build traps on the line x=20 from y=28 to y=108 with step=16.
def buildWestLine():
# Complete this function:
for y in range(28, 209, 16):
hero.buildXY("fire-trap", 20, y)
pass

buildNorthLine()
buildEastLine()
buildSouthLine()
buildWestLine()
hero.moveXY(40, 94)
``````

made a couple fixes to my code but its still not going through with it all

``````# Protect the village with fire traps.
# Mine all passages in four directions.
# You have 80 seconds before the ogres attack.

# Build traps on the line y=114 from x=40 to x=112 with step=24.
def buildNorthLine():
for x in range(40, 113, 24):
hero.buildXY("fire-trap", x, 114)

# Build traps on the line x=140 from y=110 to y=38 with step=18.
def buildEastLine():
# Complete this function:
for y in range(110, 39, 18):
hero.buildXY("fire-trap", 140, y)
pass

# Build traps on the line y=22 from x=132 to x=32 with step=20.
def buildSouthLine():
# Complete this function:
for x in range(132, 33, -20):
hero.buildXY("fire-trap", x, 22)
pass

# Build traps on the line x=20 from y=28 to y=108 with step=16.
def buildWestLine():
# Complete this function:
for y in range(28, 209, -16):
hero.buildXY("fire-trap", 20, y)
pass

buildNorthLine()
buildEastLine()
buildSouthLine()
buildWestLine()
hero.moveXY(40, 94)
``````

it does the north and south sides but completely skips the west and east sides

hahaha im just stupid and i solved it

was it the fact that you cant use y’s in for loops?
snicker

also mark this as solved

You can use y in for loops though.
It’s just a variable name.

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