Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- inp_string = 'Nobody expects the spanish inquisition'
- inp_string = inp_string.lower()
- hold_dict = {}
- unique = [i for i in set([x for x in inp_string]) if i != ' ']
- for i in unique:
- hold_dict[i] = inp_string.count(i)
- sorted_dict = dict(sorted(hold_dict.items(), key=lambda x: x[1], reverse=True))
- print(sorted_dict)
Advertisement
Add Comment
Please, Sign In to add comment