如何在python中打印不带方括号和撇号的新行词典列表

2024-06-17 09:47:46 发布

您现在位置: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)

Tags: andname列表inputblue名字词典ask