Can we perform the same operations on multi-line strings that we perform on other strings?
Yes, operations like concatenation can be performed to combine multi-line strings with single-line strings because strings created using the two techniques are both actually of the same type.
Representing String Literals in Python
In Python, a variety of techniques can be used to represent string literals in code. Each technique offers particular advantages, but all of the techniques create the same type, namely a string. Since they all create the same type of string object, concatenation can be used to combine two strings, regardless of whether they were created using different techniques.
|Technique||Reasons for Using It|
|Double quote delimiter||Can include single quotes in the string without using an escape sequence|
|Single quote delimiter||Can include double quotes in the string without using an escape sequence|
|Raw string||Can include literal escape sequences in the string|
|Triple double quote delimiter||Can include multiple lines in the string without using an escape sequence|
|Triple single quote delimiter||Can include multiple lines in the string without using an escape sequence|
Credit for this post goes to @appylpye. We hope this helps.