Python Tips: How to do slicing in Python

学習

Do you know that there are multiple ways to do slicing in Python?

Here, Anaconda’s Sophia Yang shows three ways to do slicing:
🤓 ‘L[start:stop:step]’ is the most common
😎 ‘slice(start, stop, step)’ comes up if we define our own ‘__getitem__’
🤩 ‘itertools.islice(L, start, stop, step)’ works with generators

Test it yourself with Anaconda’s cloud notebooks & follow Anaconda for more Python tips!

#shorts #python #pythonprogramming #datascience #pythontutorial

コメント

タイトルとURLをコピーしました