Skip to content

Instantly share code, notes, and snippets.

@rafiahmedd
Created April 11, 2022 20:56
Show Gist options
  • Save rafiahmedd/3472541e7b488bd9e131109dfd0db938 to your computer and use it in GitHub Desktop.
Save rafiahmedd/3472541e7b488bd9e131109dfd0db938 to your computer and use it in GitHub Desktop.
Write a program that asks the user to enter a string and prints the string's characters and their frequencies in any order and in the following format
string = input("Enter a string: ")
dictonary = {}
for char in string:
dictonary[char] = dictonary.get(char, 0) + 1
for key, value in dictonary.items():
print(f"{key}: {value}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment