-1
我想为Yahtzee的游戏做一个记分员,但是每当我把变量写入players
时,它总是会打印"I think that's enough."
请帮我理解这里发生了什么以及我如何修复它。请帮我理解这里发生了什么
#Yahtzee Scorekeeper
if __name__ == "__main__":
players = raw_input("How many people will be playing?")
if players == 1:
print "You can't play Yahtzee by yourself!"
elif players == 2:
print "Ready to start with " + str(players) + " players!"
elif players == 3:
print "Ready to start with " + str(players) + " players!"
elif players == 4:
print "Ready to start with " + str(players) + " players!"
elif players == 5:
print "Ready to start with " + str(players) + " players!"
elif players == 6:
print "Ready to start with " + str(players) + " players!"
elif players == 7:
print "Ready to start with " + str(players) + " players!"
elif players == 8:
print "Ready to start with " + str(players) + " players!"
elif players > 8:
print "I think that's enough."
另请注意,您的代码非常重复;情况2-7的代码是相同的,所以可以简单地进行简化。 – jonrsharpe 2015-04-05 22:23:45