Loading section...

What is a String?

Concepts: pyStringBasic

A string is a sequence of characters. It can contain letters, numbers, spaces, punctuation, and special symbols. In Python, strings are created by enclosing text in quotes. Python does not care whether you use single quotes (') or double quotes ("). Both create the same type of string. Choose the style that makes your code more readable. Choosing Quote Styles The main advantage of having two quote styles is that you can include one type of quote inside a string wrapped with the other: If you need both types of quotes in the same string, you can use escape sequences or triple quotes. Try picking different quote styles below to see what works. Escape Sequences An escape sequence is a backslash (\) followed by a character. It tells Python to treat the next character specially. Here are the mo