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/all-equal.md Normal file
View File

@ -0,0 +1,21 @@
---
title: Check if list elements are identical
tags: list
cover: fallen-leaves
firstSeen: 2019-08-20T11:39:18+03:00
lastUpdated: 2020-10-11T13:40:42+03:00
---
Checks if all elements in a list are equal.
- Use `set()` to eliminate duplicate elements and then use `len()` to check if length is `1`.
```py
def all_equal(lst):
return len(set(lst)) == 1
```
```py
all_equal([1, 2, 3, 4, 5, 6]) # False
all_equal([1, 1, 1, 1]) # True
```