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 149 of 179Python List Copy: Shallow vs Deep Copy Explained
Learn how to copy lists in Python correctly: assignment vs shallow copy vs deep copy, how nested lists behave, and when to use each.
Python reverse() vs reversed(): Key Differences
Python reverse vs reversed: Understand the difference between Python's list.reverse() method and the reversed() function, including memory behavior, use cases, and code examples.
Python reversed() Function: Syntax and Behavior
python reversed function: Learn how Python's reversed() function returns a lazy iterator, works with lists, strings, and ranges, and differs from reverse() and slicing.
Reverse a Python List: In-Place, Iterator, or Slicing
Learn the three ways to reverse a Python list—in-place mutation, reversed() iterators, and slicing—and when each approach fits your code.
Python Reverse List: Three Ways to Reverse a List
python reverse list: Learn the three main ways to reverse a list in Python: reverse(), reversed(), and slicing with [::-1], including memory and performance tradeoffs.
Python List Sort vs Sorted: In-Place vs New List
Learn how Python's list.sort() and sorted() differ: in-place mutation vs a new sorted list, performance, stability, and which to use.
Python sorted() Function: Syntax, Key, and Behavior
Learn how Python's sorted() function works: its syntax, key and reverse parameters, stability guarantees, and when to use it instead of list.sort().
How to Sort Python Lists with sort() and sorted()
Learn how to sort Python lists using sort() and sorted(). This guide covers key functions, reverse order, sort stability, and memory tradeoffs.
Counting Occurrences in a Python List with list.count()
Learn how Python's list.count() counts exact matches, see where equality can surprise you, and find out when collections.Counter or a generator with sum() is a better choice.
Python List index: Finding Element Positions
python list index: Learn how to use Python's list.index() to locate elements, handle missing values, and understand its performance tradeoffs.