Using Quotes Inside Strings
In Python programming, when using strings, an opening string with a quote
must match the ending quote. When you begin a string using a double
quotation mark, Python takes the next double quotation mark as the ending
of the string. This applies to a single quotation mark.
If you decide to use double quotes inside a string, you have to place them
inside single quotes. The example below will show it better.
statement = ‘Fred is “a boy that lives in New York”’
let’s assume you want to use both single and double quotes in a string. In
this situation, you have to escape the single, and double quote misses up by
using a backslash (\). The example below will demonstrate it.
statement_in_single = ‘Fred “own\’s a wonderful car in his garage”’
statement_in_double = “Fred \ ‘own’s a wonderful car in his garage\””
Do'stlaringiz bilan baham: |