[Solved] Zig zag and zoom help (python)

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:
        9 -= n
    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)

it says illegal expression for augmented assignment

you can’t change the value of a number.

what do you mean? by you can’t change the value of a number?

So you’ll have to do n=9-n

thanks fro the help I got the error away but the third zig zag does not work

Do the same for

n -=15
and make it
n=n-15

1 Like

Mod15 is supposed to be the other way. instead of n-=15 it should be n=15-n

tried but the hero stops after the first zig zag now

wait I change again but now it trys to escape but fails

Can i see your equipment please?

And also, don’t change the first def mod15, for mod9, it is supposed to be n-=9 not 9-=n

@Chaboi_3000 mod 15 actually is n -= 15, not n = 15 - n.

Take 22 as an example. its mod 15 should be 7. However if you use n = 15-n, it will be -7, which doesn’t make sense.

IK that, see my last post dude.

@Torazo_TOKUDA did you beat the level yet?

No, not yet. I think

I’m sorry but I’m not on a apple computer so I can’t take screenshot.
but my health is 918
and my attack is the runesword

now it says the code is very slow or a infinite loop

oh by the way here is my code:

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-n
    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)

the max is 35.7 sec

Do the same that you did with mod 15: n-=9 instead of n=9-n

this is my code now

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)

It trys to dodge the arrow but fails