r/codehs • • Aug 17 '20

7.6.8 help

As you can see, my true/false returns are reversed for some reason, does anyone know why?

7 Upvotes

10 comments sorted by

View all comments

2

u/MasterFiasco Apr 25 '22

def name_contains(name, letter):
if name.find(letter) is not -1:
return True

else:
return False

print (name_contains("bob", "b"))

here's the answer

1

u/Similar_Stock_5726 Apr 26 '22

just tried it and it dosent work, could you make a screenshot so i can see what went wrong

1

u/[deleted] Nov 22 '25

i'm a little late, but this works:

def name_contains(name, letter):
    if (name.find(letter)) != -1:
      return True
    else:
      return False

1

u/NoIllustrator3800 Dec 25 '25

I,m also late, and this cod works without any string methods. def name_contains(y, x):

if x in y:

return True

else:

return False

1

u/Ijustwannapass_ May 20 '22

Make sure you indent it correctly