Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mingrammer/023cf9bd80dccbd93620ae1b51096502 to your computer and use it in GitHub Desktop.
Save mingrammer/023cf9bd80dccbd93620ae1b51096502 to your computer and use it in GitHub Desktop.
numbers = [1, 2, 3, 4, 5, 6]
# The left side of unpacking should be list or tuple.
*a, = numbers
# a = [1, 2, 3, 4, 5, 6]
*a, b = numbers
# a = [1, 2, 3, 4, 5]
# b = 6
a, *b, = numbers
# a = 1
# b = [2, 3, 4, 5, 6]
a, *b, c = numbers
# a = 1
# b = [2, 3, 4, 5]
# c = 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment