List slicing in Python

Опубликовано: 08 Март 2024
на канале: Python Morsels
656
38

In Python, slicing looks like indexing with colons (:). You can slice a list (or any sequence) to get the first few items, the last few items, or all items in reverse.

Read an article version of this video at https://pym.dev/slicing/

Find more Python screencasts at https://pym.dev/screencasts/

00:00 Getting the first N elements from a list
00:28 Slicing makes a new list
00:37 The start index is inclusive but the stop index is exclusive
01:27 Default slice start/stop values
01:50 Why the stop index isn't included in slices
02:38 Negative indexes work too
03:01 Out-of-bounds slicing is allowed
03:41 The slice step value
04:38 Slicing works on all sequences
05:03 The most common uses for slicing in Python
05:20 Use slicing to get "slices" of sequences in Python

#Python


Смотрите видео List slicing in Python онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Python Morsels 08 Март 2024, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 656 раз и оно понравилось 38 людям.