Nov-05-2019, 10:23 AM
Hi there!
I started learning Python with the help of "Python Crash Course" by Eric Matthes. The progress is good, but I stuck at one of the exercises and sadly, the book doesn't have solutions given away. I tried checking several tutorials before asking here, but no luck.
Here's the task:
I got this far:
I started learning Python with the help of "Python Crash Course" by Eric Matthes. The progress is good, but I stuck at one of the exercises and sadly, the book doesn't have solutions given away. I tried checking several tutorials before asking here, but no luck.

Quote:Make several dictionaries. In each dictionary, include keys and values. Store these dictionaries in a list. Next, loop through your list
and as you do print everything you know about each dictionary.
I got this far:
name1 = {'key': 'value', 'key2': 'value2', } name2 = {'key3': 'value3', 'key4': 'value4', } name3 = {'key5': 'value5', 'key6': 'value6', } names = [name1, name2, name3] for name in names: #????? for keys, values in name.items(): print("\t" + keys + ":" + values)The code prints out the keys and values just fine, but even after trying many alternatives, I can't print out the names of the dictionaries. I only manage to print out the whole dictionary. My goal for the print output is this:
name1: key:value key2:value2 name2: key3:value3 key4:value4 name3: key5:value5 key6:value6Any help is much appreciated!