Python string quotes: Handling an apostrophe inside a string

Python string quotes: Handling an apostrophe inside a string

A classic Python mistake: What’s wrong with this code?

s = 'What's your name?'

The string uses ” as delimiters. But it also contains a ‘ inside. Solutions:

s = "What's your name?"  # Delimit with ""
s = 'What\'s your name?' # Escape literal ' with \