Kebab file names

This commit is contained in:
Angelos Chalaris
2023-04-27 22:00:06 +03:00
parent b9c77eb413
commit f6a215e9e3
107 changed files with 0 additions and 0 deletions

21
snippets/most-frequent.md Normal file
View File

@ -0,0 +1,21 @@
---
title: Most frequent element
tags: list
cover: secret-tree
firstSeen: 2019-10-12T00:40:49+03:00
lastUpdated: 2020-11-02T19:28:27+02:00
---
Returns the most frequent element in a list.
- Use `set()` to get the unique values in `lst`.
- Use `max()` to find the element that has the most appearances.
```py
def most_frequent(lst):
return max(set(lst), key = lst.count)
```
```py
most_frequent([1, 2, 1, 2, 3, 2, 1, 4, 2]) #2
```