March 13, 2019 · kata python

Kata #4: Printer Errors

I tried the "Printer Errors" kata on codewars (, and found that no-one had submitted an answer that matched my own that I could see in the first few pages (I'm sure that a few would have been submitted though).

Given a string of letters, return a value representing how many letters were not between a-m compared to the total number of letters.
e.g. 'abx' -> '1/3'

Give my caesar cipher blog a read if you haven't already, as it uses the same method here to solve it and goes into more detail.

def printer_error(s):
    errors = s.translate(str.maketrans('', '', 'abcdefghijklm'))
    return f'{len(errors)}/{len(s)}'
  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket