I have a list with 5 elements, x+2, x^3+x^2+x+2, x^3+x^2+2, x^3+2x^2+2x+2, x^3+2x+2. I am trying to get a big list with elements like (x+2)(x^3+x^2+x+2), (x+2)(x^3+x^2+x+2)(x^3+x^2+2)
and so on. One element multiply the other four to get a new element. The only way I know is to use For loop to do it, but it doesn't give me the right list. Here is what I have:
L = ['x+2','x^3+x^2+x+2','x^3+x^2+2','x^3+2x^2+2x+2','x^3+2x+2']
for i in range(0,len(L)):
for j in range(1,len(L)):
for k in range(2,len(L)):
for l in range(3,len(L)):
for m in range(4,len(L)):
print L[i],L[j],L[k],L[l],L[m]
I have many repeat elements, I want to know to how to avoid to have those repeat elements while generate the list. Can someone tell me how to do it?