import itertools a =['2','4','6','8'] b = itertools.permutations(a,3) cnt =0 for ele in b: print(''.join(ele)) cnt +=1 print( cnt )