Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# 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