-3

How do I print out the dictionary lists like this?:

Tino Black
Alex Blue
Meow Red
Woof White

I want the left column to be the name and right column to be colours for each name.

Here are my codes:

ask = input("Name and colour: ")
colourList = {}

while ask:
  name, colour = ask.split()
  colourList[name] = colour
  ask = input("Name and colour: ")

print(colourList)
Not_A_Hacker
  • 101
  • 1
  • 8

1 Answers1

2

You can do this, for example:

for name, color in colourList.items(): # this is actually a colourDictionary
    print(name, color)
ForceBru
  • 43,482
  • 10
  • 63
  • 98