I have a question. I use combinations to get different combinations from a list. However, if I wish to get a more specific combinations with ascending order(3D,4D,5D), but not (4D,5D,8D), how should I do?
for example:
from itertools import combinations
cards = ["3D", "4D", "5D", "6D"]
comb = []
for j in combinations(cards, 3):
comb.append(list(j))
for j in combinations(cards, 4)):
comb.append(list(j))
But I got an output like:
["3D", "4D", "5D"], ["3D", "4D", "6D"], ["3D", "5D", "6D"], ["4D", "5D", "6D"], ["3D", "4D", "5D", "6D"]
how can I get an output like this?
[["3D", "4D", "5D"], ["4D", "5D", "6D"], ["3D", "4D", "5D", "6D"]]