Please do not give solution in image format thanku Compute their Cartesian product, AxB of two lists. Each list has no more than 10 numbers. For example, if the user supplies the two input lists: A = [1,2] B = [3,4] then the Cartesian product output should be: AxB = [(1,3),(1,4),(2,3),(2,4)] I am having an issue with identifying where I am going wrong for the code below as it relates to the question above. Def cartisian product (List_A, List_B): AxB = [ ] for A in number_set list_A: for B in list_B: AxB.append((A,B)) print('AxB = ', calculation_list) def cartesian_values(number_set1, number_set2): calculation_list = [ ] for A in number_set1: for B in number_set2: calculation_list.append((A,B)) print('AxB = ', calculation_list) cartesian_values(number_set1, number_set2)
Please do not give solution in image format thanku
Compute their Cartesian product, AxB of two lists. Each list has no more than 10 numbers.
For example, if the user supplies the two input lists:
A = [1,2]
B = [3,4]
then the Cartesian product output should be:
AxB = [(1,3),(1,4),(2,3),(2,4)]
I am having an issue with identifying where I am going wrong for the code below as it relates to the question above.
Def cartisian product (List_A, List_B):
AxB = [ ]
for A in number_set list_A:
for B in list_B:
AxB.append((A,B))
print('AxB = ', calculation_list)
def cartesian_values(number_set1, number_set2):
calculation_list = [ ]
for A in number_set1:
for B in number_set2:
calculation_list.append((A,B))
print('AxB = ', calculation_list)
cartesian_values(number_set1, number_set2)
Step by step
Solved in 5 steps with 1 images