oter

Sequences can be sliced and accessed with indices from "summary" of Fluent Python by Luciano Ramalho

In Python, sequences such as lists and tuples can be sliced and accessed using indices. Slicing allows you to extract a portion of a sequence by specifying a start and end index. The result is a new sequence that contains the elements from the original sequence within the specified range. Indices in Python are zero-based, which means that the first element in a sequence has an index of 0. You can use positive indices to access elements from the beginning of a sequence and negative indices to access elements from the end. For example, sequence[-1] accesses the last element in a sequence. Slicing in Python is inclusive of the start index and exclusive of the end index. This means that sequence[2:5] includes elements with indices 2, 3, and 4, but not 5. If you omit the start index, Python assumes you want to start from the beginning of the sequence. Similarly, if you omit the end index, Python assumes you want to go until the end of the sequence. You can also specify a step value when slicing a sequence. For example, sequence[0:5:2] returns every second element from indices 0 to 4. The step value can be negative, which allows you to reverse a sequence by slicing it with a step of -1. Slicing and indexing are powerful features of Python sequences that allow you to manipulate and access elements efficiently. By understanding how to slice and access sequences with indices, you can work with data in a more flexible and expressive way.
    oter

    Fluent Python

    Luciano Ramalho

    Open in app
    Now you can listen to your microbooks on-the-go. Download the Oter App on your mobile device and continue making progress towards your goals, no matter where you are.