就像定义了一个函数并让它运行一样,它会返回一个结果,但是如何在字符串中使用这个结果呢?因为现在我有一段代码
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“串起来”(我说得通吗?)但我知道怎么做
目前没有回答
相关问题 更多 >
编程相关推荐