String Functions startswith and endswith in Python

How to effectively utilize the startswith and endswith functions in Python

python recipes strings

The string functions startswith and endswith in Python are typically used like in the following example:

s = 'devlabs.ninja'
print(s.startswith('dev')) # True
print(s.endswith('ninja')) # True

But we can also use an tuple with multiple options to check for both function:

s = 'devlabs.ninja'
test = ('dev', 'labs', 'ninja')
print(s.startswith(test)) # True
print(s.s.endswith(test)) # True

The functions will return True if one of the options is included.