-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