I'm new to python but I know other somewhat similar languages quite well, like C#. I am trying to get all pairs for a given array and was wondering why the code at the bottom doesn't output the following:
(7, 2) (7, 3) (7, 9)
(2, 7) (2, 3) (2, 9)
(3, 7) (3, 2) (3, 9)
(9, 7) (9, 2) (9, 3)
Instead the output is:
(7, 2) (7, 3) (7, 9) *Which is correct*
*Skips 2 entirely*
(3, 2) (3, 9) *Doesn't cover (3, 7)*
*Skips 9 entirely*
Any help would be appreciated. Thanks
Code:
weights = [7, 2, 3, 9]
for weight in weights:
secWeights = weights
secWeights.remove(weight)
for sec in secWeights:
print(weight, sec)