Question DSA-HASH-0005
EasyWhat is the output of this code?
freq = {}
for ch in "aba":
freq[ch] = freq.get(ch, 0) + 1
print(freq)
- A.
{'a': 3}
- B.
{'b': 1, 'a': 2}
- C.
Show answer and explanation
Answer: D
The loop counts each character: a appears twice and b once.