0

I have a list: ['1','2','3','4']

I would like to find out all combination within the list but not allow duplicated values ("1|2"=="2|1")

Output:

1|1
1|2
1|3
1|4
2|2
2|3
2|4
3|3
3|4
4|4
list=['1','2','3','4']
list2= list
for img1 in list:
    for img2 in list2:
        print(img1,"|",img2)
    list2.remove(img1)
martineau
  • 119,623
  • 25
  • 170
  • 301
Tho H
  • 33
  • 3
  • pls use `list2 = ['1', '2', '3', '4']` or `list2 = list.copy()`. This is why https://stackoverflow.com/a/2612815/16182150 – Trock Sep 02 '21 at 10:23
  • Cool!! it works. but i would like to ask what is the difference between them. – Tho H Sep 02 '21 at 10:29

0 Answers0