Compare commits
2 Commits
6be0a0233e
...
39b258ffec
| Author | SHA1 | Date | |
|---|---|---|---|
| 39b258ffec | |||
| 524581e2fc |
17
solution23.py
Normal file
17
solution23.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
def most_frequent_value(d: dict) -> tuple:
|
||||||
|
frequency = {}
|
||||||
|
for value in d.values():
|
||||||
|
if value in frequency:
|
||||||
|
frequency[value] += 1
|
||||||
|
else:
|
||||||
|
frequency[value] = 1
|
||||||
|
max_value = None
|
||||||
|
max_count = 0
|
||||||
|
for value, count in frequency.items():
|
||||||
|
if count > max_count:
|
||||||
|
max_count = count
|
||||||
|
max_value = value
|
||||||
|
return(max_value, max_count)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
print(most_frequent_value({"a": 1, "b": 2, "c": 1, "d": 3}))
|
||||||
Loading…
Reference in New Issue
Block a user