Count numbers
Input
[1, 2, 1, 3, 2]
Output
{1: 2, 2: 2, 3: 1}
1 appears twice, 2 appears twice, 3 appears once.
Full lesson preview
Return a dictionary mapping each distinct item to how many times it appears in a list.
Problem statement
Task
Examples
Input
[1, 2, 1, 3, 2]
Output
{1: 2, 2: 2, 3: 1}
1 appears twice, 2 appears twice, 3 appears once.
Input format
Output format
Constraints
Samples
Input
["a", "b", "a"]
Output
{'a': 2, 'b': 1}
Counts for each string item.