← Back to challenges

Broken Keyboard

PythonHardstringsarrays

Instructions

Given what is supposed to be typed and what is actually typed, write a function that returns the broken key(s). The function looks like:

find_broken_keys(correct phrase, what you actually typed)

Examples

find_broken_keys("happy birthday", "hawwy birthday") ➞ ["p"]

find_broken_keys("starry night", "starrq light") ➞ ["y", "n"]

find_broken_keys("beethoven", "affthoif5") ➞ ["b", "e", "v", "n"]

Notes

  • Broken keys should be ordered by when they first appear in the sentence.
  • Only one broken key per letter should be listed.
  • Letters will all be in lower case.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Sum of Decimals