dict1 = { "a": ["apple", "abandon", "ant"], "b": ["banana", "bee", "become"], "c": ["cat", "come"], "d": "down", } x = input() if x == 'd':#这题考字典结合for循环的可迭代对象,题目要求把输入当做字典的键,并输入值对应的单个单词,观察给出的字段,发现前三个都是以列表作为值,最后一个是以单词作为值,进行for循环读列表单词的时候,需要把'd'区分开来,不区分的话,回把单词拆成字母打印 print(dict1['d']) else: for i in dict1[x]: print(i,end = ' ')#在 Python 中,end=' ' 是 print() 函数的一个可选参数,用于指定在打印输出结束后要添加到输出末尾的字符,默认情况下,end 参数的值是换行符 \n。 通过设置 end=' ',你可以改变 print() 函数在打印输出结束后添加的字符为一个空格。