我試圖做一個非常簡單的21點遊戲。當你得到兩張牌時,如果它們都是整數或字符串,一切都沒問題,但如果兩張牌發出的是字符串和整數,我會得到一個錯誤。作爲一個整數處理一個字符串
我該如何做到這一點,如果你得到了7和女王處理,女王將被視爲10,總共給你17?
#imports
import random
Jack = 10
Queen = 10
King = 10
Ace = 1 or 11
Cards = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'Jack', 'Queen', 'King', 'Ace']
#Faces = Jack, Queen, King, Ace
print('Welcome to Blackjack!\n\nHere are your cards: \n ')
Card1 = random.choice(Cards)
Card2 = random.choice(Cards)
Total = Card1 + Card2
print(Card1,'and a', Card2, '. Your total is', Total)
#print(int(Jack + Ace))
你到目前爲止嘗試過什麼?向我們展示用於轉換爲整數的方法的代碼,並解釋其失敗的原因。 – HyperNeutrino