I’m making a choose your own adventure game, it’s quite simple, but I wanted to add a blackjack minigame to the tavern. The way I do this is by having two randomly generated numbers (signifying the two cards) and then adding them up for both to player and the dealer. Unfortunately I do not know how to add variables to strings, here’s what I’ve tried. I’m a bit new when it comes to programming.
if answer == "Blackjack" and playhand1 <= 21:
answer = input("Your hand is", + playhand1 + "the dealer's hand is", + dealhand1
>Solution :
Try this:
answer = "Your hand is, " + str(playhand1) + " and the dealer's hand is, " + str(dealhand1)
The above should work assuming playhand1 and dealhand1 are both integer values.