Python Rules Of Coding: String literals
In the above code, the string literal is “Hello, World!” with quotation marks and the string value is Hello, World! without quotation…

print(" Hello, World! ")
In the above code, the string literal is “Hello, World!” with quotation marks and the string value is Hello, World! without quotation marks. In short, the string value is the output from a string literal code. Therefore we understand that string literals and string values are not the same.
Sometimes we need quoting a source code in string values. For this why we have to add additional formatting to string literals so that we get our expected string values as output.
Quotes
We can use double quotes to enclose a string literals if we want to embed single quotes within a string value
"He says, 'Hello dear!' "
Output the string value:
He says, ‘Hello dear!’
Same way, use single quotes to enclose the string literals and embed double quotes within the string value.
st = 'He says, "Hello dear!" 'print(st)
Output the string value:
He says, “Hello dear!”
Multiple Lines
Sometimes it needs to print strings on multiple lines with grouped, orderly and formatted as a poem, lyrics, letter.
In this case, we can use triple double quotes (“ “ “) or triple single quotes (‘ ‘ ‘)
" " " Multiple lines string literals. Enclosed by triple double-quotes. " " " ''' Multiple lines string literals. Enclosed by triple single-quotes. '''
Escape Characters
To format the string literals in a specific way we can use
Escape character. Along with another character, Escape character begins with the backslash ( \ ) .
Here is a list of some escape characters from w3schools:

str = 'It\'s OK.'print(str)
Output:
It’s OK.
st = "Embed backslash \\ in string value." print(st)
Output:
Embed backslash \ in string value.
We can also remove whitespace by using the backslash ( \ ) escape character. Learn more
There is another kind of string value called Raw strings. Formatted string literals can be outputted as a string value by using an escape character ‘ r ‘ in front of a string literals.
print(r"Rony says,\"The balloon\'s color is black.\"")
Output
Rony says,”The balloon’s color is black.”
Originally published at https://hive.blog on May 5, 2020.