Is there another way to calculate the number of occurrences without using a dictionary like this code? I mean, I want the same result as this code but without the dict.
This code displays:
apple 3
bread 2
orange 1
Code:
txt = ["apple", "bread", "apple", "orange", "apple", "bread"]
dic ={}
for c in texte:
lettres[c] = lettres.get(c, 0) + 1
for i in sorted(lettres):
print(i,lettres.get(i))