I am trying to print the permutations of all the members in a list,but my script is printing the permutations of only last member of list i.e 'DMNCT'.
from itertools import permutations
element_all=['EESE', 'TTDT', 'SAIFE', 'DMNCT']
i=0
for i in range (len(element_all)):
perms = [''.join(p) for p in permutations(element_all[i])]
print perms
It seems that my for loop is not working correctly.I am fairly new to python.Any help would be appreciated.
forloop, you're overwriting the previous value ofperms. You'll need to save them somewhere (append to a list, maybe?).