Lost Viking help please

So I’m on the lost viking level and whenever I press run it says "Line 25: moveXY requires 2 numbers as arguments. y is NaN which is type ‘number’, not ‘number’."
Does anybody get this?

# You MUST click on the HELP button to see a detailed description of this level!

# The raven will tell you what to use for your maze parameters!
SLIDE = 10
SWITCH = 7
SKIP = 11

# How many sideSteps north of the Red X you've taken.
sideSteps = 1

# How many steps east of the Red X you've taken.
steps = 1

# Multiply this with steps to determine your X coordinate. DON'T CHANGE THIS!
X_PACE_LENGTH = 4

# Multiply this with sideSteps to determine your Y coordinate. DON'T CHANGE THIS!
Y_PACE_LENGTH = 6

# The maze is 35 steps along the X axis.
while steps <= 35:
    xpos = steps * X_PACE_LENGTH
    ypos = sideSteps * Y_PACE_LENGTH
    # Take the next step:
    self.moveXY(xpos, ypos)
    # Increment steps and sideSteps as appropriate, taking into account the special rules.
    if steps % SWITCH == 0:
         x *= -1

    if steps % SKIP == 0:
        x *= 2

    if steps - 1 % SKIP == 0 and steps != 1:
        x /= 2

    sideSteps += x

    if sideSteps > SLIDE:
        sideSteps = 1
    elif sideSteps < 1:
        sideSteps = SLIDE

    steps += 1

The error message is telling you that the second argument you’re passing in (the Y argument,) is NaN (not a number.)

There is a problem in your code where you are turning a number into another type. (For example, adding a null-type to a number.)

How would I fix that?

Well since Lost Viking is a challenge level, I won’t be too specific:

Look at the error and see what the problem is. Then, go through the code line-by-line to see if you can see if you can spot where the problem lies.

Use self.say() to help debug.

1 Like