Skip to content

Instantly share code, notes, and snippets.

@tienhieuD
Created August 3, 2018 12:04
Show Gist options
  • Save tienhieuD/ac6e672d6d3a0d55c7b3f4b4a10319fb to your computer and use it in GitHub Desktop.
Save tienhieuD/ac6e672d6d3a0d55c7b3f4b4a10319fb to your computer and use it in GitHub Desktop.
nstr = [1, 2, 3, 4, 5, 6, 4, 3, 2, 3]
lst = [nstr[i:i + 3] for i in range(0, len(nstr), 3)]
print(lst)
# [[1, 2, 3], [4, 5, 6], [4, 3, 2], [3]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment