List slicing in Python

Veröffentlicht am: 08 März 2024
auf dem Kanal: 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


Auf dieser Seite können Sie das Online-Video List slicing in Python mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Python Morsels 08 März 2024 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 656 Mal angesehen und es wurde von 38 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!