Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Having trouble making a blackjack minigame for my game

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading