Ask a py keyword parameter problem

ss = "012345.78"
print (ss.endswith (".", 1,7))

the result is that True, has no doubt ~

but I inadvertently used the keyword argument to pass
ss.endswith ("., start=1, end=7)
ss.endswith ("., 1, end=7)

* * did not expect to throw exceptions
TypeError: endswith () takes no keyword arguments**

what is the reason, please?

Mar.09,2021

originally endswith () does not have start and end parameters. Its function prototype is like this

.
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.
Type:      builtin_function_or_method

you can use the endswith (xx, start=N, end=M) method only if the function prototype is
endswith (suffix, start=0, end=-1)
or
endswith (suffix, * * kwargs)
.

Menu