Real Python Live: The Joys of itertools
Python's itertools module can replace a lot of the loops you write by hand, often with code that's shorter, clearer, and easier on memory. We'll take everyday loops, find the itertools tool that does the job better, and look at the traps worth knowing about. We'll also see when a plain loop is still the better choice.