我正在制作一個選擇你自己的冒險游戲,這很簡單,但我想在酒館中添加一個二十一點小游戲。我這樣做的方法是使用兩個隨機生成的數字(表示兩張牌),然后將它們相加給玩家和莊家。不幸的是,我不知道如何將變數添加到字串中,這是我嘗試過的。我對編程有點陌生。
if answer == "Blackjack" and playhand1 <= 21:
answer = input("Your hand is", playhand1 "the dealer's hand is", dealhand1
uj5u.com熱心網友回復:
試試這個:
answer = "Your hand is, " str(playhand1) " and the dealer's hand is, " str(dealhand1)
假設 playhand1 和 dealhand1 都是整數值,上述內容應該可以作業。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/413716.html
標籤:
