Spy among us, help me!

I need some help with this
I don’t know what is wrong with this code
I have tried it but it thinks that everyone is a spy and it kills them all

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
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.")

Looks like you forgot something.

You have no logic for

return True

so true returned in any case

what languege are u using c++?

if c++ put this
if(character == letter) {
return true;
}

if python if
character == letter:
return true

Thanks but I know how to solve it. I’m much better at programming now.

true og has returned
anyway @itik pls don’t res 6 YEAR OLD TOPICS!!!1!1!!

1 Like

why u don’t end the topic

what lvl are u in now can u help me

u mean hes 6 year old wow noice

Only moderators can end topics.

why only moderator(abc)

its not 6 year its 2023 now its 7 year

:face_with_diagonal_mouth: Just the way discourse is

why its the way why can it’s not be another way

which lvl are u on can u help me

can u stop being rude itik

1 Like