为我的游戏制作二十一点迷你游戏时遇到问题
Having trouble making a blackjack minigame for my game
我正在做一个选择你自己的冒险游戏,这很简单,但我想在酒馆里添加一个二十一点小游戏。我这样做的方法是使用两个随机生成的数字(表示两张牌),然后将它们加起来给玩家和庄家。不幸的是我不知道如何向字符串添加变量,这是我尝试过的。在编程方面我有点陌生。
if answer == "Blackjack" and playhand1 <= 21:
answer = input("Your hand is", + playhand1 + "the dealer's hand is", + dealhand1
试试这个:
answer = "Your hand is, " + str(playhand1) + " and the dealer's hand is, " + str(dealhand1)
假设 playhand1 和 dealhand1 都是整数值,以上应该可以工作。
我正在做一个选择你自己的冒险游戏,这很简单,但我想在酒馆里添加一个二十一点小游戏。我这样做的方法是使用两个随机生成的数字(表示两张牌),然后将它们加起来给玩家和庄家。不幸的是我不知道如何向字符串添加变量,这是我尝试过的。在编程方面我有点陌生。
if answer == "Blackjack" and playhand1 <= 21:
answer = input("Your hand is", + playhand1 + "the dealer's hand is", + dealhand1
试试这个:
answer = "Your hand is, " + str(playhand1) + " and the dealer's hand is, " + str(dealhand1)
假设 playhand1 和 dealhand1 都是整数值,以上应该可以工作。