Help with spy among us

for some reason it keeps saying that the spy is a friend. pleas help

# 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
        if character == "Zozo":
            return True
    # The letter isn't in the word, so return False
    return False
while True:
    
    
    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.")

Take a look at the function header for letterInWord:

def letterInWord(word, letter):

You haven’t used the variable letter in the function.


Also, the while True: is not necessary.

2 Likes

Note: manually finding the name won’t help, because it will change every time. You actually have to find the name of the spy with the function.

just change this and u will done
"character == “Zozo”: "=
character == letter:

Hi @itik, please don’t necropost. The original poster isn’t even active anymore.
Thanks,
Marmite

1 Like

wat is nevcriopotst 20000000000000000000000000000000000 character

necroposting is when you post something on a topic that’s either very inactive or has been solved. It’s when you post on a 2-3 year old topic when no one in the topic is active. Thanks and please don’t necropost
-Ritic

1 Like