{}
CODE VISUALIZER
Master DSA, Python and C with step-by-step code visualization.
See it in action
CODE VISUALIZER
Master DSA, Python and C with step-by-step code visualization.
See it in action
run-icon
main.py
def roll(vec, shift): n = len(vec) shift = shift % n return vec[-shift:] + vec[:-shift] if shift else vec print(roll([1, 2, 3, 4, 5], 2))
Output