SimeonTs

SUPyF Dictionaries - 03. Letter Repetition

Jun 23rd, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. """
  2. Dictionaries and Functional Programming
  3. Проверка: https://judge.softuni.bg/Contests/Practice/Index/945#2
  4.  
  5. SUPyF Dictionaries - 03. Letter Repetition
  6.  
  7. Problem:
  8. You will be given a single string, containing random ASCII character.
  9. Your task is to print every character, and how many times it has been used in the string.
  10.  
  11. Examples:
  12. -----------------------------------------------------------------
  13. Input:                                                  Output:
  14. aaabbaaabbbccc                                          a -> 6
  15.                                                        b -> 5
  16.                                                        c -> 3
  17. -----------------------------------------------------------------
  18. """
  19. letters_input = [item for item in input()]
  20.  
  21. letter_repetition = {}
  22.  
  23. for letter in letters_input:
  24.     if letter not in letter_repetition:
  25.         letter_repetition[letter] = letters_input.count(letter)
  26.  
  27. for key, value in letter_repetition.items():
  28.     print(f"{key} -> {value}")
Add Comment
Please, Sign In to add comment