Example of Character Count in a String

Example of Character Count in a String.

input_string = "programming"
ip = " ".join(input_string).split()
char_count = {}
for i in input_string:
    if i not in char_count:
        char_count[i] = 1

#Output: {‘p’: 1, ‘r’: 2, ‘o’: 1, ‘g’: 2, ‘a’: 1, ‘m’: 2, ‘i’: 1, ‘n’: 1}

Well, that depends on the context. You’ve computed a Python dict which
maps characters to a count. dict objects do use a hash table to
distribute their keys for efficient lookup.

What’s the context of the term “hashmap” you’re using?

Sorry, I don’t quite understand. Are you only trying to show an example of code for others to learn from? Or did you have a question, encounter some problem, want to change the code in some way, etc.?

Either way: to format the code properly, use the backtick symbol (`) on the lines above and below, not a quotation mark. On a standard US keyboard, you get this symbol with the key that’s above the tab key (to the left of the 1 digit key).