Why doesn't submitting work in The Spy Among Us? It only works when I run it

# The inner gate can hold against ogres for a long time.
# But one of these peasants is an OGRE SPY!
# We have a hint: the spy's name contains the letter "z"

# This function should check if a word contains a certain letter
# A string is an array of characters! You can loop over it just like an array.
def letterInWord(word, letter):
    for i in range(len(word)):
        character = word[i]
        # If character is equal to letter, return True
        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("Fenzdrel" + " is a spy!")
        hero.say("Mary" + " is a friend.")


Because you didn’t complete the function and your hero always say the same name. Level are randomized so when you run in “submit” mode, you get the new random seed. For that level it can another peasant.


I finished the level by submitting it many times, but do you type all the names in the hero.say is a spy command?


Are you trying “complete” levels or learn something about programming?

You can try to fix letterInWord function.


Maaan, that is the kind of “exploit” that not even I would have thought of. +1 for the effort. :smile: