Why are these three functions not the same, when I include the else: I always get false.
Why does the false return sit out of the if statement or underneath it without an else?
def letter_check(word,letter):
for i in word:
if i == letter:
return True
return False
````Preformatted text`
print(letter_check("strawberry","a"))
def letter_check(word,letter):
for i in word:
if i == letter:
return True
return False
print(letter_check("strawberry","a"))
def letter_check(word,letter):
for i in word:
if i == letter:
return True
else:
return False
print(letter_check("strawberry","a"))
True
True
False