#!/usr/bin/env python3 def test(cgcombis, cgcombis_orig, fixedstr=""): if len(cgcombis) == 0: return if len(cgcombis) == 1: for comb in cgcombis[0]: print("COMBI: " + fixedstr + comb) else: for combi in cgcombis[0]: fixedstr += combi cgcombis_new = [cgcombis[i] for i in range(1, len(cgcombis))] test(cgcombis_new, cgcombis_orig, fixedstr) fixedstr = fixedstr[:-1] print() INPUT = [["1","2"],["3","4","5"],["6","7","8","9"], ["0", "1"]] test(INPUT, INPUT)