Below is a small part of what I'm trying to run, it gets stuck on the final line k=2 elements = [i for i in np.arange(k)] Sk = PermutationGroup([Permutation(list(perm)) for perm in itertools.permutations(elements)]) factorial = int(sp.special.factorial(k)) for i in np.arange(factorial): trace_list = np.zeros(Sk.cycles) ... The problem is that the list index is out of range because Sk doesn't seem to include the identity element when you list all of the elements: k=2 elements = [i for i in np.arange(k)] Sk = PermutationGroup([Permutation(list(perm)) for perm in itertools.permutations(elements)]) print(Sk) PermutationGroup([(0 1)]) I know that the identity exists as Sk.identity, but I just want to be able to simply loop through Sk without having to put special cases for every time the identity is needed. Is there a way to do this? Continue reading...