This is the code with list
function commented out:
from collections import Counter
a = input().split()
b = map(int, a)
##c = list(b)
d = Counter(b)
print(d)
Input: 1 2 3
Output: Counter({1: 1, 2: 1, 3: 1})
However, when i remove the hashtags, assign c
to list(b)
and rerun the code this occurs:
Input: 1 2 3
Output: Counter()
My question is, Why is it that the counter output values differ if b is not being assigned any new type? From what i know, b would not be affected by this operation? Please forgive me if its a dumb question, I am still quite new to coding. Thanks!