Why does Python join two String Literals without operators?

Question:

Why does python join two String without any type of operator such as sum?

This:

>>> 'Perro' 'Lobo'
'PerroLobo'

Does the same as this:

>>> 'Perro' + 'Lobo'
    'PerroLobo'

Answer:

Well, when a programming language does something like this, it is usually by design. In this case, as explained in the documentation :

Multiple adjacent string literals (delimited by whitespace), possibly using different quoting conventions, are allowed, and their meaning is the same as their concatenation

Translated:

Multiple adjacent (whitespace-delimited) string literals, possibly using different citation conventions (that is, single or double quotes), are allowed and their meaning is the same as their concatenation.

Scroll to Top