如何在python中以新行打印字典列表,不带方括号和撇号



如何像这样打印出字典列表?

Tino Black
Alex Blue
Meow Red
Woof White

我希望左列是名称,右列是每个名称的颜色。

这是我的代码:

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

您可以这样做,例如:

for name, color in colourList.items(): # this is actually a colourDictionary
print(name, color)

最新更新