See the docs:
str.join(iterable)
Return a string which is the concatenation of the strings in the iterable
iterable
. The separator between elements is the string (str
) providing this method.
So ''.join(L)
joins the elements of L
, separating them from each other by the empty string.
You might wonder why this method seems so backwards (for example, why not L.join('')
? The reason is simple: The result will always be a string, and the separator will always be a string. And since the method should work on any iterable that can provide a string representation of its members, it makes sense to define it once on the string separator instead of multiple times for each possible iterable.