← back to unit
Medium
# power tools medium
Letter Inventory
The letterpress printer counts every letter in the phrase before setting the type. 🔤
You get a lowercase phrase (may include spaces — ignore them) and then a line of queries (comma-separated letters). For each query letter, print <letter> <count> on its own line.
Example:
Input: phrase = "banana bread", queries = ["a", "b", "z"]
Output:
a 4
b 2
z 0
Tallying letters (ignoring the space) gives a=4, b=2, and z never appears at all, so its count reads as 0.
💡 need a hint?
pt-letter-inventory.py🔒 given lines are locked — write your code in between
loading...