因此,当您定义一个函数并让该函数运行时,它将返回一个结果,但是如何在字符串中使用该结果?因为现在我得到了一些像
的代码def chosen_snack():
while True:
print "What's your favourite type of snack?"
fav_type = raw_input()
if "sweet" in fav_type:
print "So you like sweet snacks? I'll give you a lollipop!"
elif "savoury" in fav_type:
print "So you like savoury snacks? I'll give you some crisps!"
else:
print "sorry, what did you say? I only have savoury and sweet snacks."
continue
return
chosen_snack()
print "What will you do, eat it or save it?"
choice = raw_input("> ")
if "eat it" in choice:
print "Well I also would eat %s" % chosen_snack()
就像我想让所选的零食(所以一些薯片或棒棒糖)被%s“束缚”(我有意义吗?)但是如何