Skip to content

Instantly share code, notes, and snippets.

@imazine
Last active June 25, 2025 00:48
Show Gist options
  • Save imazine/6e0c1fd45015141307fb4645db5b6e09 to your computer and use it in GitHub Desktop.
Save imazine/6e0c1fd45015141307fb4645db5b6e09 to your computer and use it in GitHub Desktop.
Cartersian product in Python
from itertools import product
alist = [[1,2], [3], [4,5,6]]
def cartersian(l):
return list(product(*l))
cartersian(alist)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment