0
example problem
>>> 'Brian\'s mother: He\'s not the Messiah. He\'s a very naughty boy!' 'Brian's mother: He's not the Messiah. He's a very naughty boy!'. i dont understand
2 Respuestas
+ 5
The lesson is teaching the use of escape characters when printing strings.
In the sentence example there a 5 quotation marks.
The outside quotation marks are meant to encapsulate the string sentence.
The inner quote marks are for the English language syntax.
Python will try to encapsulate the string from the first pair of quote marks, so to prevent this, an escape character is used (\) to tell Python to bypass the following quote mark.
This continues to happen until a quote mark is encountered which has not been escaped.
The string is then encapsulated.
Try printing 'Brian's',
Then try printing 'Brian\'s'
You will see the difference in the output
0
it was in the strings topic, i dnt understand if i have to remove \ from first line or i have to use \ where i will use 's ?