Can multi-line strings be concatenated with other strings?


#1

Question

In the context of this exercise, if we have a multi-line string, can it be concatenated with other strings?

Answer

Yes, operations like concatenation can be performed on multi-line strings, the same way they are used on single-line strings. Both types of strings (single-line and multi-line) can be concatenated with each other.

Single-line and multi-line strings share many properties and most of their functionality is the same, with the main differences being the surrounding quotes (single vs triple), and the requirement that single-line strings must be on one code line, whereas multi-line strings are not limited to this, and can span any number of lines.

One thing to note is that, when concatenating a multi-line string with a single-line string, the result string will most likely be multi-line as well, due to it preserving the lines from the multi-line string.