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

Lesson 3: f-strings, putting values neatly into text

13 min read·14 Oct 2026
Module 3 · Lesson 3 · About 40 minutes · Needs: Module 3 Lessons 1 and 2 (strings, string methods), Module 2 (numbers, str())

The situation

Amira wants a printed slip for every overdue loan, to tuck inside the reminder she hands over the counter. She starts with Ben. His loan is L13, The War of the Worlds, borrowed on shelf day 21, so it was due on day 35. Today is day 44: Ben is 9 days late and owes 180 pence.

You already hold those values in variables. What you lack is a tidy way to put them into text, with pence shown as pounds and values lined up. That is this lesson.

KETTLE AND PAGE ------ Booknook loan slip ------ Loan L13 Member Ben Book The War of the Worlds Due day 35 Days late 9 Owes £1.80 labels left, values right
The slip Amira wants for Ben's loan: labels in a left column, values lined up on the right, every line 32 characters wide.

The rest of this part opens with an account

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