該代碼添加一組牌(在遊戲的21點)我怎樣才能使這種加法更簡單?
# Rules
print("Dont enter Ace, Jack, Queen or king in the first 4 Inputs")
print("You will be told when to enter those")
print("if you dont have a card just enter 0")
# Line break
print("")
card1 = int(input("What is your first card: "))
card2 = int(input("What is your second card: "))
card3 = int(input("What is your third card: "))
card4 = int(input("What is your fourth card: "))
# Line break
print("")
# print("King = 10 \nJack = 10 \nQueen = 10 \nAce = 11 or 1 ")
AJKQ = (input("Any Ace, jack, Queens or kings: "))
AJKQ2 = (input("Any Ace, jack, Queens or kings: "))
# Line Break
print("")
print(card1 + card2 + card3 + card4 + AJKQ + AJKQ2)
代碼需要加起來得到了用戶的卡,並與王牌輸出插孔王后和國王
林還ifs和elifs不是很好,那麼最好的辦法是將它壓縮成更小的代碼?
如果你的代碼正在工作,這可能是在這裏的主題。嘗試提交到https://codereview.stackexchange.com/。 – Chris
爲什麼讓你的用戶按下「Enter」這麼多次? 'cards = input('輸入所有的卡片,並在它們之間留有空格')。split()**沒有人喜歡與電腦進行擴展對話。 – FMc
@FMc - 如果輸入是全部數字,則按下Enter鍵而不是空格鍵可能會更容易,因爲許多鍵盤上的數字鍵盤上都有一個Enter鍵。 – TigerhawkT3