Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python cartesian product

# initialize lists
listA = [1, 4, 6, 7]
listB = [1, 3]
  
# Construct Cartesian Product Tuple list
# using list comprehension
res = [(a, b) for a in listA for b in listB]
  
# printing result
print("The Cartesian Product is : " + str(res))
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #python #cartesian #product
ADD COMMENT
Topic
Name
7+3 =