Skip to content

Instantly share code, notes, and snippets.

@sravi4701
Created February 23, 2018 23:21
Show Gist options
  • Save sravi4701/802804249673d1af0cf5c0e7f0447295 to your computer and use it in GitHub Desktop.
Save sravi4701/802804249673d1af0cf5c0e7f0447295 to your computer and use it in GitHub Desktop.
Unpacking a sequence into separate variables
# comma_separated_variables = sequence
# given a data in the form of list
data = ['Ravi', 21, (1996, 12, 5)]
# extract name, age, dob from data
name, age, dob = data
print(name) # Ravi
print(age) # 21
print(dob) # (1996, 12, 5)
# It works with any sequence eg.
s = 'hello'
a, b, _, c, d = s
print(b) # e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment