就像在我的另一个问题中,这个是关于我正在研究的挖掘游戏,有一个错误,当我运行它时它会这样做:when I test it
它关闭程序而不是一遍又一遍地执行它,我想创建一个循环,但我不知道如何为这类问题创建循环类型。请帮忙吗?
这是代码:`
import random
start = raw_input("Welcome to the gold mine game! type 'start' to start playing ")
if str.upper(start) == ("START"):
default_cash = 14
print "you have %s cash" % default_cash
choices = raw_input("What would you like to do? type 'dig' to dig for ores or type 'shop' to buy equitment ")
if str.upper(choices) == ("DIG"):
ores = ["nothing", "nothing", "nothing", "nothing", "nothing", "nothing", "nothing", "nothing", "nothing", "nothing", "nothing", "iron", "iron", "iron", "iron", "silver", "silver", "gold"]
ores_random = random.choice(ores)
print "you found %s!" % ores_random`
答案 0 :(得分:2)
你可以添加一个while循环来保持程序继续运行,直到给出一个结束的信号。像:
SELECT customer_id, FLOOR(dbms_random.value+0.5)
FROM customers
编辑:对不起。忘了重新选择输入。插入输入请求以在必要条件之后在while循环中分配选项