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

The spy among us help me


# The inner gate can hold for a long time.
# However, one of these peasants is an OGRE SPY!
# There is a hint! The spy's name has the letter "z"

# This function checks for a specific letter in a word.
# A string is just an array! Loop over it like an array
def letterInWord(word, letter):
    for i in range(len(word)):
        character = word[i]
        # If character is equal to letter, return True
        for Z in range(len(word)):
            return True
    # The letter isn't in the word, so return False
    return False


spyLetter = "z"
friends = hero.findFriends()

for friend in friends:
    friendName = friend.id
    if letterInWord(friendName, spyLetter):
        # Reveal the spy!
        hero.say(friendName + " is a spy!")
    else:
        hero.say(friendName + " is a friend.")


The hero says that everyone is a spy

Why have you written this?
It states here what to do:

You can almost write it out in Python and it will work. Think about what it could be telling you to do.
Break it up into words:

if character equals letter return True
# look at that and see how you could change the syntax to make it error free python. (you don't have to change much)

Danny