I want to implement a HashMap in Python. I want to ask a user for an input. depending on his input I am retrieving some information from the HashMap. If the user enters a k
Python Counter is also a good option in this case:
from collections import Counter counter = Counter(["Sachin Tendulkar", "Sachin Tendulkar", "other things"]) print(counter)
This returns a dict with the count of each element in the list:
Counter({'Sachin Tendulkar': 2, 'other things': 1})