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
Popular Python guides
Most readLatest Python guides
Page 136 of 179Python Reverse Range: How to Iterate Backward
python reverse range: Learn how to create and use reverse ranges in Python with range() and reversed(), including practical examples and common pitfalls.
Python Negative Range: Descending Sequences with range()
Learn how to use Python range() with a negative step to generate descending sequences, handle edge cases, and avoid off-by-one errors.
Python range syntax: start, stop, step
Understand the python range syntax for start, stop, and step, including lazy evaluation, negative steps, and practical loop patterns.
Python range: How It Works and When to Use It
python range: Understand Python's range object: how it generates sequences lazily, its memory efficiency, and when to convert it to a list.
Python Hashable Dictionary Keys: How to Use Them Correctly
Learn what makes Python objects hashable, how to use custom classes as dictionary keys, and how to avoid mutable-key pitfalls.
Python Dictionary Key Requirements
Python dictionary keys must be hashable and unique. This article explains why stable, effectively immutable keys are the safe choice and how to use custom objects correctly.
Python Dict Order Preservation
Understand Python's dict order preservation guarantee, its history, practical implications, and when OrderedDict is still worth using for compatibility.
Python dict vs defaultdict: Choosing the Right Mapping
Compare Python's dict and defaultdict: understand missing-key behavior, performance trade-offs, and decide which mapping fits your data-processing needs.
Python KeyError Handling: Safe Dictionary Access
Learn practical ways to handle Python KeyError when accessing dictionaries: use .get(), setdefault, defaultdict, and try/except, with trade-offs for each approach.
Python Missing Dictionary Key: Safe Access and Defaults
Practical guide to handling missing dictionary keys in Python: KeyError, get(), setdefault(), defaultdict, and when to use each approach.