I am a beginner in python and I would like your opinion on a more sophisticated way to write the code that follows. I want the code to iterate through the whole list (x) of items, count how many times each item appears and store the output in a new list (z). Here is the code (it works as it is) :
x = ["apple", "orange", "cherry", "apple"]
def new_list(a):
z=[]
for i in x:
y = x.count(i)
(z.append(y))
return z
print(new_list(x))