Strings

Explore Python's string data type, including how to create strings, use escape characters, access characters by index, understand immutability, and work with Unicode.

String data manipulation

A string is a sequence of characters. In Python, a string is a fundamental data type that can hold any combination of characters, including letters, numbers, special symbols and punctuation marks, whitespace (spaces, tabs, newlines), and even emojis. A string can also contain a single character or be entirely empty.

For the Python interpreter to treat a sequence of characters as strings, they need to be enclosed within single, double, or triple quotation marks (either three single quotes on each end of the string or three double quotes on each end). Note that these are not considered a part of the string. Let’s have a look at the following playground to understand when each of the three styles is used. Here are some examples of strings:

Get hands-on with 1400+ tech skills courses.