Update most_frequent.md

This commit is contained in:
Angelos Chalaris
2019-10-12 13:14:17 +03:00
committed by GitHub
parent 907bb89705
commit 82b8ec08f6

View File

@ -3,9 +3,9 @@ title: most_frequent
tags: list,beginner tags: list,beginner
--- ---
Returns the most frequent element in a `list`. Returns the most frequent element in a list.
Use `set(list)` to get the unique values in the `list` in combination `max()` to find the element that has the most appearances. Use `set(list)` to get the unique values in the `list` combined with `max()` to find the element that has the most appearances.
```py ```py
def most_frequent(list): def most_frequent(list):
@ -13,6 +13,5 @@ def most_frequent(list):
``` ```
```py ```py
numbers = [1,2,1,2,3,2,1,4,2] most_frequent([1,2,1,2,3,2,1,4,2]) #2
most_frequent(numbers) #2 ```
```