I have a list of Twitter hashtags named li
. I want to make a new list top_10
of the most frequent hashtags from that.
So far I have done (#):
li = ['COVID19', 'Covid19', 'covid19', 'coronavirus', 'Coronavirus',...]
tag_counter = dict()
for tag in li:
if tag in tag_counter:
tag_counter[tag] += 1
else:
tag_counter[tag] = 1
popular_tags = sorted(tag_counter, key = tag_counter.get, reverse = True)
top_10 = popular_tags[:10]
print('\nList of the top 10 popular hashtags are :\n',top_10)
As the hashtags are not case-sensitive, I want to apply case-insensitivity while creating my tag_counter
.