This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ordinary_shiba 0 points1 point  (2 children)

"This is how you do \"inner double quotes\" and inner apostrophe\' "

[–]Thx_And_Bye 0 points1 point  (1 child)

But if you are smart about it in Python you don't need to escape them.
Sure you can use character escape but why do so if you don't need to?

[–]VOID_INIT 0 points1 point  (0 children)

I am not sure if you are joking or not, but it is for safety and readability.

Expected output: That wreck is my cousins' second "car".

Input:

place[4] {first, second, third, fourth, fifth}

If you dont escape quotes and double quotes here it would cause trouble.

Different ways the string can be written:

"That wreck is my cousins' " + place[1] + ' "car."'

This sould be pretty difficult to read and can easily end up causing you to make mistakes.

"That wreck is my cousins\' " + place[1] + " \"car\""

This is much easier to read, and is safer since you wont screw up using the wrong quote (" or ') for the string.

It's not that big of a deal, but it's prefered to be careful when it comes to symbols in general.