Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Zig Zag and Zoom - Python

So basically, i tried zig zag and zoom and on the third zigzag he gets stuck in his walking animation, standing there, doing nothing. Here is my code

# Escape from Death Valley!
# Move by with a zigzag pattern using real modulo functions.

# This function returns a value from 0 to 15:
def mod15(n):
    while n >= 15:
        n -= 15
    return n

# This function should return a value from 0 to 9:
def mod9(n):
    # While n is greater or equal to 9, subtract 9 from n:
    while n >= 9:
        n - 9
    return n

# Don't change the following code:
while True:
    time = hero.time
    if time < 30:
        y = 10 + 3 * mod15(time)
    else:
        y = 20 + 3 * mod9(time)
    x = 10 + time
    hero.moveXY(x, y)

I have tried reloading the page but it doesnt work.

Error says Line 13 Statement Execution Limit Reached.

I guess CodeCombat likes levels when they’re fast. Unfortunately this is a slow level.

Try changing n - 9 to n -= 9 like the n -= 15 part.

1 Like

Add a equal sign in between - and 9
Lydia

wheres the level? Is it subscriber?

oh wait no its in the desert

oh ok … Try what @Lydia_Song said and it should work :smiley: