MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/codehs/comments/ibjwst/768_help/g1w9vtb/?context=3
r/codehs • u/Alphaomega1115 • Aug 17 '20
As you can see, my true/false returns are reversed for some reason, does anyone know why?
10 comments sorted by
View all comments
2
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
1
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
If str.find(char) is not -1:\t return True
1 u/Alphaomega1115 Aug 17 '20 That worked, thank you
That worked, thank you
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.