You might want to think about using a dictionary to hold the counts of your items:
d = {}
for x in y:
d[x] = d.get(x, 1) + 1 And perhaps giving your variables and functions longer and more descriptive names. It's all too easy to forget what does what several months down the line:
bag = {}
for item in list:
bag[item] = bag.get(item, 1) + 1 (A bag being the technical name of the data struct your function creates.)