Last Updated: February 25, 2016
·
288
· gilesa

To check for the existence of a substring, use "in" not "find"

If you just need to check if a string contains a substring, use:

if 'sub' in substring:

instead of:

if substring.find( 'sub' ) != -1:

These work the same in the background, but the first is much easier to understand and shorter to write.