I'm trying to write a program were a user enters a list, the program reads through a list and rotates the numbers in the list one position for each interaction until the numbers reach starting position.
Output should look like that
Input a list: 1 2 3 4
1,2,3,4
2,3,4,1
3,4,1,2
4,1,2,3
1,2,3,4
I have written a program that achieves the desired result but it dosent let the user input a number, it is just hardcoded into the program. How can I alter my code to produce the desired output?
see my code bellow:
def rotation(series): # change this to input a list
for i in range(len(series) + 1):
print(series)
series = series[1:] + series[:1]
rotation([1,2,3,4])