Update syntax highlighting, update allUnique

This commit is contained in:
Angelos Chalaris
2019-08-20 10:09:53 +03:00
parent 59fd9ad9a8
commit 0f405f0da9
35 changed files with 73 additions and 72 deletions

View File

@ -6,12 +6,12 @@ Returns the `n` maximum elements from the provided list. If `n` is greater than
Use `list.sort()` combined with the `deepcopy` function from the inbuilt `copy` module to create a shallow clone of the list and sort it in ascending order and then use `list.reverse()` reverse it to make it descending order. Use `[:n]` to get the specified number of elements. Omit the second argument, `n`, to get a one-element list
```python
```py
def max_n(lst, n=1, reverse=True):
return sorted(lst, reverse=reverse)[:n]
```
```python
```py
max_n([1, 2, 3]) # [3]
max_n([1, 2, 3], 2) # [3,2]
```