Created
December 16, 2018 09:58
-
-
Save mobileappconsultant/86faa5868a53bbdb63f30ec8c3d44bdd to your computer and use it in GitHub Desktop.
Very simple script to practice the syntax for function unpacking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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