Accessing list elements: indexing and slicing in Python.

Опубликовано: 28 Март 2026
на канале: PatchyPython
119
0

Try this code in your browser: click here
https://tinyurl.com/5cud7uzd

List elements are numbered, like the houses in a street, but starting at 0 (so that the last element of a list of n elements is actually number n-1). The indexing operator (a pair of square brackets) allows you to read or write a particular element of a list; conveniently, it can also be applied to retrieve individual characters in a string. The "len" function lets you know how many elements there are in a list, and you can use an indexing technique known as "slicing" to extract entire sub-lists. For more information and to try out the code, click on the link above - a notebook will open in your browser, no need to install Python on your machine.

Embedded video, also part of the following courses:
Computer Programming at Queen Mary, University of London
FREE Colab notebook: https://tinyurl.com/3xjmpf94
Coding for Scientists at Queen Mary, University of London
FREE Colab notebook: https://tinyurl.com/yedumefr