Advertisement
here2share

# list_shift_by_value.py

Sep 7th, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.20 KB | None | 0 0
  1. # list_shift_by_value.py
  2.  
  3. d = range(0,20)
  4. def shift(seq, n=1):
  5.     n = n % len(seq)
  6.     return seq[n:] + seq[:n]
  7. #
  8. for i in '!'*5:
  9.     d=shift(d)
  10.     print d
  11. d=shift(d,3)
  12. print d
  13. d=shift(d,30)
  14. print d
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement