The Ultimate Guide to Slicing in Python

preview_player
Показать описание
The idea of slicing is simple. You carve out a subsequence from a sequence by defining the start and end indices. But while indexing retrieves only a single character, slicing retrieves a whole substring within an index range.

Use the bracket notation for slicing with the start and end position identifiers. For example, word[i:j] returns the substring starting from index i (included) and ending in index j (excluded). Forgetting that the end index is excluded is a common source of bugs.

Slicing Tutorial:

BONUS Booklet: Master Slicing, Once and For All

Become a better coder! Download the 5x Python Cheat Sheet Course (PDF). It’s free!

🐍 Cheating in Python? Of course! 🐍
Рекомендации по теме
welcome to shbcf.ru