[Solved] how to get all possible combinations when both a symbol and set of symbols could have different values [closed]

You can use itertools to do this: from itertools import permutations strings = [‘a’,’b’,’c’,’d’,’ab’,’cd’,’abc’] all_combin = [s for i in range(2,len(strings)+1) for s in permutations(strings,i)] # List of all possible combinations of letters from the list num = [] for n in all_combin: if ”.join(n) == ‘abcd’: a=”” for l in n: a += str(strings.index(l)+1) … Read more