Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #contare occorrenze voti per ogni persona, restituire la persona con piu voti
- def esercizio(l):
- d = {}
- for element in l:
- if element in d:
- d[element] += 1
- else:
- d[element] = 1
- valmax = 0
- elementomax = ""
- for key in d:
- if d[key] > valmax:
- valmax = d[key]
- elementomax = key
- return elementomax
- l = ["davide","giorgio","davide","giorgio","davide","davide","francesco","sara"]
- print(esercizio(l))
Advertisement
Add Comment
Please, Sign In to add comment