This commit is contained in:
Angelos Chalaris
2019-09-18 09:05:10 +03:00
committed by GitHub
parent 022e1286c7
commit ef04bd6c2b

View File

@ -5,11 +5,11 @@ tags: list,beginner
Returns every nth element in a list.
Use `[1::nth]` to create a new list that contains every nth element of the given list.
Use `[nth-1::nth]` to create a new list that contains every nth element of the given list.
```py
def every_nth(lst, nth):
return lst[1::nth]
return lst[nth-1::nth]
```
```py