CoursePython from Scratch to Intermediate · Module 3: Strings and Text · part 22 of 75
Part 22 · Module 3: Strings and Text

Lesson 2: String methods, the tools every string carries

14 min read·14 Oct 2026
Module 3 · Lesson 2 · About 40 minutes · Needs: Module 3 Lesson 1 (indexing, slicing, len(), strings cannot change)

The situation

Amira hands you a printout of Tom's notebook. "Can you read this? I want each loan split into its date, title and name." You look at line 6:

NOTEBOOK LINE 6, AS TOM TYPED IT 04/09/2026 Emma "  lena  " back 12/09/2026 lower case, extra spaces
Line 6 holds four pieces; the name, in amber because it is messy input, is in lower case with extra spaces round it.

The line holds four pieces separated by space, hyphen, space: borrow date, title, first name, and back with the return date. The name is in lower case with extra spaces. Slicing by hand would mean counting characters on every line. Python strings come with ready-made tools for this job. This lesson teaches them on line 6, then uses them on lines 4 and 5.

The rest of this part opens with an account

Signing up is free and takes one email. Nothing to pay, and nothing renews.