Returning a different outcome outside an if/else function?


#1

Excercise 10/12

Here I tried the following:

def letter_check(word, letter):
  for char in word:
    if char == letter:
      return True
    else:
      return False

But when the program checks against letter_check("strawberry", "a") it returns False.

APPARENTLY it wants the following code despite returning False is not inline with the if statement. Can anyone tell me why this is?

def letter_check(word, letter):
  for character in word:
    if character == letter:
      return True
  return False

#2

That terminates the function before the loop has finished.