Category Built-in Methods

Python xrange: Meaning and Migration

Python xrange: Meaning and Migration

Updating Python code that uses xrange() starts with knowing which Python version the code targets. In Python 2, xrange() provides an immutable integer sequence for loops, while Python 3 uses range() for that job. This article explains what xrange() did…

Python zip() Function: Pair Iterables

Python zip() Function: Pair Iterables

Related values often arrive in separate lists, such as names in one list and scores in another. Python’s zip() function pairs items at matching positions and returns an iterator that yields tuples. I’ll explain what zip() returns and show how…

Python Write File: Choose the Right Mode

Python Write File: Choose the Right Mode

A file that already contains notes can be a place to add another line without losing what’s there. Python’s append mode writes new text at the end, while other modes can create or replace a file. I’ll explain how the…

Filter Function in Python

Filter Function in Python

When a list of records includes entries that pass a condition and entries that do not, selecting the matches calls for a test. Python’s filter() applies a test, called a predicate, to each item and returns an iterator containing the…