-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto stash before merge of "main" and "origin/main"
- Loading branch information
1 parent
5378435
commit 16a999d
Showing
2 changed files
with
20 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Write a program which counts and print the numbers of each character in a string input given by the user. | ||
# The outcome should be a dictionary. | ||
# For example, for the input 'abcdefgabc', the output should be {'a':2, 'c':2, 'b':2, 'e':1, 'd':1, 'g':1, 'f':1} | ||
|
||
user_input = input('Enter a string: ') | ||
|
||
count = dict() | ||
|
||
for string in user_input: | ||
|
||
count[string] = count.get(string, 0) + 1 | ||
|
||
print(count) |