This is the list given but can be any number of integers
list = [2,3,5,6]
This should be the outcome:
(2,2)
(2,3)
(2,5)
(2,6)
(3,2)
(3,3)
(3,5)
(3,6)
(5,2)
(5,3)
(5,5)
(5,6)
(6,2)
(6,3)
(6,5)
(6,6)
This is the list given but can be any number of integers
list = [2,3,5,6]
This should be the outcome:
(2,2)
(2,3)
(2,5)
(2,6)
(3,2)
(3,3)
(3,5)
(3,6)
(5,2)
(5,3)
(5,5)
(5,6)
(6,2)
(6,3)
(6,5)
(6,6)
You can use itertools
list(itertools.product(l, repeat=2))
[(2, 2),
(2, 3),
(2, 5),
(2, 6),
(3, 2),
(3, 3),
(3, 5),
(3, 6),
(5, 2),
(5, 3),
(5, 5),
(5, 6),
(6, 2),
(6, 3),
(6, 5),
(6, 6)]
The solution could be:
[(i,j) for i in list for j in list]
which is the "list-comprehension" version of:
result = []
for i in list:
for j in list:
result.append((i,j))
Please note that using list = something
you are overriding a python keyword.