i see how this code prints s which is 'cad' but, then it somehow backtracks to print s again which is 'cat' according to the results after i execute it. can someone walk me through how this works? it would be a great help.
def eds(k,L,s): """ starting with the k-th list in L, adds letters to the current string s """ if k >= len(L): print s else: for i in range(0,len(L[k])): eds(k+1,L,s+L[k][i]) def main(): """ enumerates letter combinations """ S = ['c','s','v'] V = ['a','e','i','o','u'] E = ['d','t','w'] L = [S,V,E] eds(0,L,"") main()
Edited 6 Years Ago by gruis: n/a