Advertisement
IT45200

Untitled

Apr 2nd, 2020
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  1. num_list = [1, 5, 4, 3, 45, 45, 47, 1, 2, 2]
  2. my_dict = {}
  3. for elem in num_list:
  4.     if elem in my_dict:
  5.         my_dict[elem] += 1
  6.     else:
  7.         my_dict[elem] = 1
  8. for key, value in my_dict.items():
  9.     print('number',str(key),'appeared', str(value), 'time(s)')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement