I’ll try to explain what I’m trying to do with an example:
Number = ["1","9","7"]
So I want it to return:
[["1","9","7"],["9","7","1"],["7","1","9"]]
What I get is:
[["7","1","9"],["7","1","9"],["7","1","9"]]
For some obscure reason it replaces my first results with the last one.
def Get_Rotations(Number):
Rotations = []
x = 0
while x < len(Number):
Number.insert(0,Number.pop())
Rotations.append(Number)
x += 1
print(Rotations)
return Rotations
You have to create copies of
Number. You are manipulating the same list in each iteration and append that list three times toRotations. Therefor you see three timesNumberin it’s “end state”.That minor change should do the trick! 😉