Did You Mean? with difflib

easy
Unit 11 · Stdlib0/3 to milestone

CLIs suggest corrections for typos. Using the standard library's difflib, implement:

  • suggest(word, options, n=3, cutoff=0.6): up to n close matches, best first (case-insensitive, but return the options' original spelling)
  • unknown_command_message(cmd, commands): returns "Unknown command 'x'.", followed by Did you mean 'y'? with the single best match, or Did you mean one of: 'a', 'b'? when there are two or three matches, and nothing extra when there are none
#stdlib#strings#fuzzy-matching2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Did You Mean? with difflib · TechGradify