这是我的 Python 初学者编程挑战代码
food = input("What is your favorite entree? ")
dessert = input("What is your favorite dessert? ")
print("\nI am going to assume that your favorite meal is" , food + dessert)
代替打印
I am going to assume that your favorite meal is
正在打印
('\nI am going to assume that your favorite meal is', 'steakcookies')
我需要更改什么?
请您参考如下方法:
您将其视为 Python 3 的 print() 函数。当您在 Python 2 中执行此操作时,它会打印您提供给它的对象,这是一个 tuple。在 Python 3 中,这些括号将描述函数调用,每个包含的对象都是传递给函数的参数。
如果您希望它按您期望的方式运行,请在代码顶部导入 print() 函数:
from __future__ import print_function
从该程序的那一点开始,print 将引用函数,而不是语句。
