Created
October 16, 2021 11:10
-
-
Save h3ik0th/c8881391b727bf070c10c6a5a5f0ae78 to your computer and use it in GitHub Desktop.
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
# on the web, I've seen an alternative: | |
# the use of functions with a loop to unpack and print dictionary items | |
# the double asterisk ** in the function call unpacks the dictionary | |
# the **kwargs argument accepts an undetermined number of keyword arguments | |
# it needs 4 lines of code where the list comprehension needed 1 to print the dictionary | |
def print_dict(**kwargs): | |
for key,value in kwargs.items(): | |
print(f'{key}:{value:.1f}') | |
# call function: | |
print_dict(**acc_dict) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment