We already learnt about strings in Python3 Basics: Numbers, Strings and Functions, but in this tutorial we are going to learn a little more about strings in Python and also see some helpful functions Python provides for strings.
String literals can be enclosed by either single or double quotes, although single quotes are more commonly used. For example, 'Hello World' or "Hello World".
To type in some special characters, you have to type in a backslash escape. For example, \' is a single quote, \" is a double quote, \\ is a backslash, \t is a tab and \n is a newline. For example:
type=codeblock|id=py3_string_escaping|autocreate=python3print('Alice said \'How do you do?\'.\nBob replied, \'Very well thank you!\'')
Alice said 'How do you do?'.Bob replied, 'Very well thank you!'
A double quoted string literal can contain single quotes without any fuss (e.g. "I didn't do it") and likewise single quoted string can contain double quotes.