PythiloLesson 3 of 30 · progress kept in this browser

Strings and f-strings

A string is an immutable sequence of characters. Methods return new strings and leave the original alone.

  • s.strip() removes surrounding whitespace.
  • s.split() breaks on any run of whitespace and returns a list.
  • "-".join(parts) glues a list back together.
  • s.upper(), s.lower() and s[0] do what they look like.
Your task

Write receipt_line(name, price, qty) returning the name padded to width 10, a space, x and the quantity, a space, then price * qty right-aligned in width 7 with 2 decimals. Write initials(full_name) returning the upper-case first letter of each word.

Next: Numbers