rockmanvnx6

count_frequency.py

Aug 14th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  1. def showArr(dict):
  2.     for key in dict:
  3.         print(key);
  4.  
  5. a = input("Type in the string: ")
  6. store = {};
  7. for i in a:
  8.     if(i not in store):
  9.         store[i] = 1
  10.     else:
  11.         store[i] += 1
  12. store = sorted(store.items(), key=lambda kv: kv[1])
  13. showArr(store)
Advertisement
Add Comment
Please, Sign In to add comment