StudyToCert

All certifications / PCEP / Lessons

PCEP – Certified Entry-Level Python Programmer PCEP-30-02 · Domain 3: Data collections: tuples, dictionaries, lists and strings

Strings: indexing, slicing (including [::-1]), immutability and comparison

▶ Watch the overview video

Last reviewed September 30, 2026 · Leer en español

A string is an immutable sequence of characters. Because it is a sequence, it supports the same indexing and slicing rules as lists and tuples, so everything you learned there carries over. s = "Python" has length 6; s[0] is 'P', s[5] and s[-1] are both 'n', and s[6] raises IndexError: string index out of range. Python has no separate character type: indexing a string returns another string of length one. You can loop over a string character by character with for ch in s:, and in tests for a substring, so "th" in s is True.

Free account

Keep reading for free

Create a free StudyToCert account to read the rest of this lesson: 7 more sections, 6 key terms, a real-world example, an exam tip and self-check questions. Every lesson, lab and practice test is free with an account.

Sign up free Log in

Study PCEP for free
A week-by-week plan with every lesson, quizzes, checkpoint tests, a practice exam and hands-on labs.
Open the PCEP study plan