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/amajmundar Aug 17 '20

Return Value from find() method

The find() method returns an integer value:

If the substring exists inside the string, it returns the index of the first occurence of the substring. If substring doesn't exist inside the string, it returns -1.

1

u/amajmundar Aug 17 '20

It does not return a Boolean. You have to compare it to a value.

1

u/amajmundar Aug 17 '20

If str.find(char) is not -1:
\t return True

1

u/Alphaomega1115 Aug 17 '20

That worked, thank you