2.3 The String Data Type
The Python data type for handling characters rather than numbers is the string. Strings are often used to represent words, names, or even a single character.
To define a string in Python, you surround the characters with either single, double, or triple quotes. Also, like ints and floats, strings are objects that can be named.
Strings are surrounded by quotes and can contain any characters: letters, spaces, numbers, and even punctuation marks. When you have a string that contains a single quote, use double quotes around the string. When you have a string that contains double quotes, use single quotes around the string. Strings can also be surrounded by triple single quotes (''') or triple double quotes ("""), although ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access