Advertisement
Guest User

Untitled

a guest
Apr 25th, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. def main():
  2.  
  3. a = input('Enter numbers:')
  4. a = a.split()
  5. alist = list(a)
  6. new_numbers = []
  7. for n in alist:
  8. new_numbers.append(int(n))
  9. alist = new_numbers
  10.  
  11. newlist = {}
  12.  
  13. for i in alist:
  14. if i in newlist:
  15. newlist[i]+=1
  16. else:
  17. newlist[i] = 1
  18.  
  19. list2 = list(newlist.keys())
  20. list3 = list(newlist.values())
  21.  
  22. for x in range(len(list2)):
  23. if list3[x] > 1:
  24. print(list2[x],'occurs',list3[x],'times')
  25. if list3[x] == 1:
  26. print(list2[x],'occurs',list3[x],'time')
  27.  
  28.  
  29. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement