编程新手。尝试用头先编程书自学。 我不能让下面的代码工作
def make_smoothie():
juice = input("What juice would you like?")
fruit = input("Ok- and how about the fruit?")
print "Thanks. Lets go!"
print "Crushing ice..."
print "Blending the %d" % fruit
print "Now adding in the %d juice" %juice
print "Finished! There's your %d and %d smoothie" %(fruit, juice)
print ("Welcome to smoothie")
another ="Y"
while another=="Y":
make_smoothie()
another = input ("How about another (Y/N)?")
不断得到的错误,果汁或水果的输入没有定义
只是一个猜测。。。如果您使用的是python2,那么使用
raw_input
而不是input
。。。(在python2中,input
将尝试评估用户对python对象的输入(整数或变量名等)。。。raw_input
将以字符串形式返回用户输入)考虑
它对我来说工作得很好,我使用的是python2.x。您提供果汁和水果的数字是因为您使用%d进行文本格式化吗?你知道吗
相关问题 更多 >
编程相关推荐