I'd like to get all the permutations of a list but without any repetitions, regardless of ordering. It's kind of hard to describe so I'll give an example. I'd really like to know the name of this operation because I use it all the time. Also a simple way to achieve this in python would really help me out. Thanks!
e.g
['foo', 'bar', 'la']
==>
['foo', 'bar']
['foo', 'la']
['ba', 'la']
Using itertools.combinations
:
>>> import itertools
>>> list(itertools.combinations(['foo', 'bar', 'la'], 2))
[('foo', 'bar'), ('foo', 'la'), ('bar', 'la')]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With