← Back to challenges

Little Dictionary

PythonHardstringsconditions

Instructions

Create a function that takes an initial word and extracts any words that start with the same letters as the initial word.

Examples

dictionary("bu", ["button", "breakfast", "border"]) ➞ ["button"]

dictionary("tri", ["triplet", "tries", "trip", "piano", "tree"]) ➞ ["triplet", "tries", trip"]

dictionary("beau", ["pastry", "delicious", "name", "boring"]) ➞ []

Notes

  • If none of the words match, return an empty list.
  • Keep the filtered list in the same relative order as the original list of words.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Eliminate Odd Numbers within a List