I see that the method str.endswithallows the parameter to suffixbe a tuple of strings :
Docstring:
S.endswith(suffix[, start[, end]]) -> bool
Return True if S ends with the specified suffix, False otherwise.
With optional start, test S beginning at that position.
With optional end, stop comparing S at that position.
suffix can also be a tuple of strings to try.
so I assumed that it also accepts a list of strings or other iterables , but when I tried this, passing the list causes an error:
In [300]: s='aaa'
In [301]: s.endswith(('a', 'b'))
Out[301]: True
In [302]: s.endswith(['a', 'b'])
TypeError Traceback (most recent call last)
<ipython-input-302-d70816089fed> in <module>()
TypeError: endswith first arg must be str, unicode, or tuple, not list
So why does it only accept a tuple of strings ?
source
share