test_miss = ["zzz","subdermatoglyphic","the quick brown fox jumps over the lazy dog"]
# From Section 11.2 of:
# Downey, A. (2015). Think Python: How to think like a computer scientist. Needham, Massachusetts: Green Tree Press.
def histogram(s):
d = dict()
for c in s:
if c not in d:
d[c] = 1
else:
d[c] += 1
return d
Copy the code above into your program but write all the other code for this assignment yourself. Do not copy any code from another source.
1
Expert's answer
2021-10-18T07:15:02-0400
import string
from collections import Counter
def count_letters(sentence):
return {c: Counter(sentence.lower()).get(c, 0) for c in string.ascii_lowercase}
Comments
Leave a comment