Skip to content

Instantly share code, notes, and snippets.

@mobileappconsultant
Created December 16, 2018 09:58
Show Gist options
  • Save mobileappconsultant/86faa5868a53bbdb63f30ec8c3d44bdd to your computer and use it in GitHub Desktop.
Save mobileappconsultant/86faa5868a53bbdb63f30ec8c3d44bdd to your computer and use it in GitHub Desktop.
Very simple script to practice the syntax for function unpacking
# declare a simple tuple and dictionary
tuple_easy = (1, 2, 3, 4, 5, 6, 6, 7)
simple_dict = {'a': 2, 'b': 1, }
# try to display their contents, observe the result
print(tuple_easy)
print(simple_dict)
# use arg unpacking to extract the contents
print(*tuple_easy)
print(*simple_dict)
# argument after ** must be a mapping, not tuple so method below won't work
# print(**tuple_easy)
# print(**simple_dict)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment