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

[SOLVED] Three Step Password Help (python)

I don’t know what’s wrong with my code, but the hero is only saying one of the characters in the message as the password. Here’s my code:

# Find the password for the gates and defeat the ogres.

# Get the secret message.
hero.moveXY(52, 50)
friend = hero.findNearest(hero.findFriends())
message = friend.message

# Get the separator symbol.
hero.moveXY(66, 34)
friend = hero.findNearest(hero.findFriends())
separator = friend.separator

# Get the index.
hero.moveXY(52, 18)
friend = hero.findNearest(hero.findFriends())
index = friend.index

# Move to the gates.
hero.moveXY(44, 34)

# Split `message` with `separator` to get an array:

# Get the password from the array of words by `index`:
password = message[index]

# Say the password:

# Defeat the ogres:
while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        while > 0:
            if hero.isReady("power-up"):
            if hero.isReady("bash"):

Where is this level? Don’t give me a link.

CodeCombat - Coding games to learn Python and JavaScript?

oops. i think it is in the mountain

this level is in the mountains

Actually, you’ve got to redefine message as message.split(seperator).
So, intead of

you’ve got to change it to

message = message.split(separator)

Thanks! It worked! (20)

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