Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save graphoarty/b6c7cd20a55bb979354a008f02392004 to your computer and use it in GitHub Desktop.
Save graphoarty/b6c7cd20a55bb979354a008f02392004 to your computer and use it in GitHub Desktop.
def cartesianProduct(setA, setB):
if len(setA) == 0:
return None
if len(setB) == 0:
return None
product = []
for elementA in setA:
for elementB in setB:
product.append([elementA, elementB])
return product
print(cartesianProduct(['a', 'b'], ['1', '2', '3']))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment