Rewrote python string permutations problem correctly