Created
April 11, 2022 20:56
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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