Advertisement
informaticage

Rimuovi duplicati e conta occorrenze

Feb 10th, 2021
703
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. numeri = [ 1, 1, 3, 4, 3, 1, 9, 2, 2 , 4 ]
  2. occorrenze = {}
  3.  
  4. for da_contare in numeri:
  5.   occorrenze_correnti = 0
  6.   for num in numeri:
  7.     if(num == da_contare):
  8.       occorrenze_correnti += 1
  9.   print(da_contare, '=>', occorrenze_correnti)
  10.   occorrenze[da_contare] = occorrenze_correnti
  11.  
  12. lista_nd = []
  13.  
  14. for chiave in occorrenze:
  15.   lista_nd.append(chiave)
  16.  
  17. print(lista_nd)
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement