Pages

Topics

Tools

↑↓navigate↵openescclose

Python guides

Every published Python guide, newest first, with practical examples you can copy into your own project.

3,965 guides across 14 topics

Topics

Latest Python guides

Diagram showing a horizontal sequence of elements with every second element highlighted and a directional step arrow above the row.
Python

Python Extended Slicing: Step and Negative Indexes

Understand Python extended slicing with the step parameter, negative indexes, slice objects, and copy behavior for lists and custom containers.

python slicingslice objectsnegative stepsequence indexing
Diagram of a Python slice object extracting a sublist from a list with start, stop, and step indices.
Python

Understanding Python's slice() Function

python slice function: Learn how to use Python's slice() function to create slice objects, apply them to sequences, and implement slicing in custom classes.

slice objectsequence slicingpython built-in functionslist slicing
A Python slice object visualized as a window over a sequence of numbered blocks, with start, stop, and step markers.
Python

Python Slice Object: Syntax and Usage

python slice object: Understand the Python slice object: how slice() works, its attributes, and how to use it for clean, reusable slicing logic in sequences.

slicingsequence indexingslice objectpython internals
Illustration of Python sequence slicing with negative step to reverse a list
Python

Python Reverse Sequence Slicing: Syntax and Behavior

Learn to reverse Python sequences with slice notation: negative steps, partial reversals, step sizes, memory trade-offs, and common pitfalls.

Pythonslicingreversestep parameter
Illustration of Python negative slicing showing a list with indices from the end, with arrows indicating reverse traversal.
Python

Python Negative Slicing: Syntax and Behavior

python negative slicing: Understand Python negative slicing: negative indices, step values, reversing sequences, common edge cases, and practical usage for lists and s...

Pythonslicingnegative indexingsequences
Diagram showing Python slice syntax with start, stop, and step parameters on a list segment.
Python

Python Slicing: Start, Stop, and Step Explained

Understand Python slicing with start, stop, and step parameters. Learn positive and negative indices, step behavior, and practical examples for lists and strings.

python slicingpython sequenceslist slicingpython step parameter
Diagram showing Python slice syntax with start, stop, and step on a sequence
Python

Python Slice Syntax: A Practical Reference

Learn how Python slicing extracts portions of lists, strings, and other sequences. Covers start, stop, step, negative indices, and reusable slice objects with code examples.

slicingsequenceslistsstrings
Diagram showing how Python slicing extracts a subrange from a sequence using start, stop, and step indices
Python

Python Slicing: Syntax, Behavior, and Edge Cases

Understand python slicing: start, stop, and step syntax, negative indices, slice assignment, copy semantics, and the edge cases that cause bugs.

pythonslicingsequenceslist-slicing
Illustration of a compact range object holding three parameters instead of a long list of integers.
Python

Python range Memory Efficiency: How range() Stays Small

Understand how Python's range object stores its defining parameters instead of materializing every value, and when list(range(...)) is still necessary.

rangememory usagelazy evaluationiteration
Illustration comparing a compact range object with a large list of numbers, symbolizing lazy vs eager memory usage in Python.
Python

Python range vs list: Key Differences and Use Cases

Learn how Python's range and list types differ in memory usage, iteration behavior, mutability, and when to choose each.

pythonrangelistmemory