+ 8
Why is .split() and .split(sep=None) works as same?
On performing the .split operation on a string we can use .split() or .split(sep=None) . Why two commands perform the same task?
3 Réponses
+ 7
The default value of the set argument is None.
You can check the docs.
+ 5
In Python, you have default arguments that kick in when you don't give an argument.
I guess, the definition of split looks somewhat like this:
def split(self,..., sep=None):
if sep==None:
...
else:
...
So by explicitly passing sep as None, you're just overwriting, what's in there anyway.