2
我的代码大部分工作完美,唯一我无法弄清楚是三种。如果出现三个相同的数字,则它们会相加得到分数。这是我现在拥有的那部分代码。我必须在Python中制作一个Yahtzee游戏。其他的工作,但我不能得到三种工作
def threeOfOne(dicelst):
total = 0
for die in dicelst:
if dicelst[0] == dicelst[1:3]:
total += die
elif dicelst[1] == dicelst[2:5]:
total += die
else:
total = 0
return total
我觉得我缺少一些非常简单的东西,但我不能得到它的工作它总是显示零。
您正在比较单个值与列表! – ti7
https://stackoverflow.com/questions/3844801/check-if-all-elements-in-a-list-are-identical – Lafexlos