Created
April 11, 2019 19:31
-
-
Save daniel-woods/db96c351da9ce8c4d5a6af6c2cbee19e to your computer and use it in GitHub Desktop.
Shifting an inputted list by an offset
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def myfnc(l, n): | |
| le = len(l) | |
| return l[n % le::] + l[:n % le:] | |
| def main(): | |
| input_list = [1, 2, 3, 4, 5] | |
| shift_rotate = 2 | |
| x = myfnc(input_list, shift_rotate) | |
| print(x) | |
| if __name__ == '__main__': | |
| main() |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ python shift_list.py
[3, 4, 5, 1, 2]