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

[SOLVED] Bugs and please help on Double Agent

hi it says an error but it doesn’t say which line it’s on.
here’s my code:

def passagePosByNum(n):
    return {"x": 60, "y": n * 12 + 8}
def onHear(event):
    message = event.message
    clearMessage = message.trim()
    n = clearMessage.len
    h = passagePosByNum(n)
    if h:
        pet.moveXY(h)
    pet.moveXY(1, pet.pos.y)
pet.on("hear", onHear)
while True:
    hero.move(pet.pos)

1 Like

Can you send me a link to the level?

https://codecombat.com/play/level/double-agent? there

1 Like

Here is the issue. Try to put this instead:

n = len(message) - len(clearMessage)

Does it work now @ActualllOLLIEpop ?

thanks, but there’s still the error

1 Like

Can you send me your current code?

here:

def passagePosByNum(n):
    k = {"x": 60, "y": n * 12 + 8}
    return k
def onHear(event):
    message = event.message
    clearMessage = message.trim()
    n = len(message) - len(clearMessage)
    h = passagePosByNum(n)
    if h:
        pet.moveXY(h)
    pet.moveXY(1, pet.pos.y)
pet.on("hear", onHear)
while True:
    hero.move(pet.pos)

1 Like

Here put

pet.moveXY(h.x, h.y)

Does it work now?

yes it worked! thanks @AnSeDra! :partying_face:

1 Like

No problem! And congratulations for completing the level! :partying_face: