Skip to content

Instantly share code, notes, and snippets.

@Sangarshanan
Last active July 9, 2018 12:47
Show Gist options
  • Save Sangarshanan/a470088292422d085b7d6195b40eaabb to your computer and use it in GitHub Desktop.
Save Sangarshanan/a470088292422d085b7d6195b40eaabb to your computer and use it in GitHub Desktop.
--------------------------------
S = 'abcdef'
N = 3
print(list(zip(*[iter(S)] * N)))
will Print: [('a','b','c'),('d','e','f')]
--------------------------------
ROTATE AN LIST
>>> from collections import deque
>>> d=deque([1,2,3,4,5])
>>> d
deque([1, 2, 3, 4, 5])
>>> d.rotate(2)
>>> d
deque([4, 5, 1, 2, 3])
>>> d.rotate(-2)
>>> d
deque([1, 2, 3, 4, 5])
--------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment