Advertisement
simeonshopov

1. Count Chars in a String

Feb 3rd, 2020
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.24 KB | None | 0 0
  1. text_input = input()
  2.  
  3. chars = {}
  4.  
  5. for char in text_input:
  6.     if ord(char) != 32:
  7.         if char not in chars:
  8.             chars[char] = 1
  9.         else:
  10.             chars[char] += 1
  11.  
  12. [print(f'{x} -> {y}') for (x, y) in chars.items()]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement