我是一个刚开始学习代码的新手。我决定用Python自己构建一个垃圾游戏。我有一个使用随机模块编写的简单程序。它工作得很好,生成了我想要的数字。但是,我想让我的程序知道在第一卷上滚动7、11、2、3和12与在随后的卷上滚动的区别。现在每卷都是全新的。我可能没有很好地表达我希望实现的目标,但我希望会有一些反馈。我的代码如下。也可以随意评论你注意到的其他事情。也许我试着在编码3周后变得太复杂了
#dice roll
import random
while True:
diceOutput=random.randint(1,6)
diceOutput2=random.randint(1,6)
diceRoll=input('Please type \'r\' to roll')
if diceRoll== 'r':
print(diceOutput)
print(diceOutput2)
else:
print('Only type \'r\'')
这里有一种将掷骰保存在列表中的方法,可以在以后的掷骰中进行检查,还可以通过抽样检查来确定掷骰是否是赢家
我认为这可能有助于让你继续完成你想要实现的目标
相关问题 更多 >
编程相关推荐