proomt

Search

Search posts, papers, and topics

All posts

Real Python50 min readtutorialintro

Strings and Character Data in Python

Summary

Python strings are immutable sequences of characters. This tutorial covers creating strings with literals and str(), using escape sequences, indexing, slicing, concatenation, and interpolation via f-strings or format().

  • Single or double quotes create string literals; triple quotes are used for multiline strings and docstrings.
  • Strings are immutable—any modification returns a new string object.
  • Escape sequences (e.g., \', \" , \\) let you include special characters inside literals.
  • Indexing (s[0]) and slicing (s[start:end]) provide direct access to characters and substrings.

Any Python developer who works with textual data should know the basics of string literals, immutability, and common manipulation techniques.

5/10

Related reading

  1. Quiz: Thinking Recursively in Python

    This is an interactive quiz from Real Python designed to test understanding of recursive thinking in Python. It covers identifying recursive structures, writing base and recursive cases, managing state, and using caching to avoid recomputation.

    Real Pythonrealpython.com1 min
  2. Python Inner Functions: What Are They Good For?

    This tutorial explains Python inner functions, which are defined inside other functions and can access nonlocal names. They are primarily used for encapsulating logic, creating helper functions to reduce repetition, building closures that retain state, and implementing decorators to extend callable behavior.

    Real Pythonrealpython.com17 minHN8