Python combinations no repeat by constraint

Posted by user2758113 on Stack Overflow See other posts from Stack Overflow or by user2758113
Published on 2013-10-23T01:02:20Z Indexed on 2013/10/23 3:54 UTC
Read the original article Hit count: 203

Filed under:
|
|

I have a tuple of tuples (Name, val 1, val 2, Class)

tuple = (("Jackson",10,12,"A"),
         ("Ryan",10,20,"A"),
         ("Michael",10,12,"B"),
         ("Andrew",10,20,"B"),
         ("McKensie",10,12,"C"),
         ("Alex",10,20,"D"))

I need to return all combinations using itertools combinations that do not repeat classes. How can I return combinations that dont repeat classes. For example, the first returned statement would be: tuple0, tuple2, tuple4, tuple5 and so on.

© Stack Overflow or respective owner

Related posts about python

Related posts about tuples