I am trying to count the number of times letters show up in a string, so i'm using the count() function which is working fine, however using multiple count() functions seems tedious since i'm trying to count 10+ letters.
def printer_error(s):
#errorLetters = ('r','s','t','u','v','w','x','y','z')
errorRate = s.count('o') + s.count('p') + s.count('q')
print(errorRate)
return
printer_error('aaaxbbbbyyhwawiwjjjwwm')
My first attempt was s.count(errorLetters) but that failed because the count() function can't take tuples or lists.
the current code is giving me the result I want but I still have to concatenate the rest of those commented out letters in the errorLetters variable, is there another way to do this that doesn't involve making 20+ concatenations?
s.countinside the loop.sum([1 if c in errorLetters else 0 for c in s])