Checkpoint

Checkpoint: The Ship's Register

A tired harbour clerk typed a ship into the register. The line is messy: odd spaces, small letters, and everything squashed together with | signs. Let's tidy it up!

This checkpoint uses the whole chapter: split, indexes, slices, strip, title, upper, int() and f-strings.

One handy fact: int(" 12 ") gives 12. It ignores spaces around the digits.

Assignment

Work from entry (don't type the answers yourself):

  1. Set parts to entry split on "|".
  2. Set name to the first part, stripped, in title case. Here that's "Captain Ada".
  3. Set port to the second part, stripped, in UPPERCASE. Here that's "MOONWELL".
  4. Set code to the first 3 letters of port ("MOO").
  5. Set crew to the third part as a number, using int().
  6. Print this line with an f-string:
Captain Ada sails from MOONWELL (MOO) with 12 crew