BEGINNER PYTHON · CHAPTER 06

Python strings for beginners

Explore Python text with indexing, slicing, traversal, searching, and string methods.

Practice Python strings →Download the chapter notebook

Understanding strings

A string is a sequence of characters. Indexes start at zero, and slices select part of the text. Strings are immutable: methods such as lower() produce a new string. Use these ideas to inspect and transform text in small, testable steps.

word = "Python"
print(word[0])    # P
print(word[1:4])  # yth
print(word.lower())  # python

A slice includes its starting position and stops before its ending position. The original word remains unchanged.

What you will practice

Work through eight coding missions, then test your understanding with ten multiple-choice questions. Each mission provides starter code, a hint, and feedback after you run it.

  1. First, last, and length — A string is a sequence; Getting the length of a string using len
  2. Walk a string backwards — Traversal through a string with a loop; Exercise 1
  3. Slice a word — String slices; Exercise 2
  4. Create a new greeting — Strings are immutable
  5. Count a chosen letter — Looping and counting
  6. Clean and normalize — String methods
  7. Find the mail host — Parsing strings
  8. Extract a numeric field — Exercises: Exercise 5

Your chapter progress is saved in this browser. Complete all 18 checks to unlock a certificate at your earned practice score, and download your notebook or grade report to keep a copy.

Read, practice, and try again

For the chapter reading, see Python for Everybody: Strings by Charles R. Severance (CC BY 4.0). ZHUDDLE adds its own practice activities and scoring. The browser runs Python after its first interpreter download; no local installation is required.

Start the strings exercises →