Category Built-in Methods

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…

Python sorted() to Sort Lists

Python sorted() to Sort Lists

Ordering a list of scores or names in Python doesn’t require writing your own sorting routine. The built-in sorted() returns a new list of the items in order and leaves the original unchanged. I’ll walk you through sorting in either…