Pluralising English Nouns

medium
Unit 16 · Strings IV0/3 to milestone

Implement pluralize(word, count=2) returning word unchanged when count == 1 and the plural otherwise, using these rules in order:

  1. irregulars: person→people, child→children, mouse→mice, man→men, woman→women, tooth→teeth, foot→feet
  2. uncountables stay the same: sheep, fish, series, species, data, information
  3. ends in s, x, z, ch, sh → add es
  4. consonant + y → ies
  5. ends in fe → ves; ends in f (except roof, belief, chef) → ves
  6. otherwise add s

Preserve the case of the first letter (Child → Children). Also implement format_count(n, word) → "1 file", "3 files".

#strings#rules2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Pluralising English Nouns · TechGradify