Some links that might be helpful for this story.
itertools
List comprehensions
Copyright 2022 Robin A. Reynolds-Haertle