import itertools
Numb = 'abxxxc'
L=list(itertools.permutations(list(Numb)))
L=[''.join(str(i) for i in x) for x in L]
K=L[::]
for i in range(len(L)):
if K[i][-1] == 'x':
del K[i]
print(L)
I have a code like this and when I run this it gives me an error.
if K[i][-1]=='x':
IndexError: list index out of range
and I have no idea why. I tried everything but still it gives me error.Can someone please help me to see where is my error ?
Edit:
L=list(itertools.permutations(list(Numb)))
L=[''.join(str(i) for i in x) for x in L]
for i in range(len(L)):
if L[i][5] == 'x':
del L[i]
print(L)