How to generate all possible combination of 2 values tuples in Python

1 Answer

0 votes
tuple1 = (3, 7)
tuple2 = (8, 2)
 
result =  [(a, b) for a in tuple1 for b in tuple2]
result = result +  [(a, b) for a in tuple2 for b in tuple1]
 
print(result)



'''
run:

[(3, 8), (3, 2), (7, 8), (7, 2), (8, 3), (8, 7), (2, 3), (2, 7)]

'''

 



answered Dec 16, 2023 by avibootz
...