Code a Game of Blackjack with Python

Blackjack Strategy Video Source & Information:

Learn how to code a command line game of Blackjack with the Python programming language.

## CHECK OUT THE FOLLOW ON VIDEO TO TURN THIS SAME CODE BASE INTO A BEST OF FIVE GAME https://youtu.be/fn61C_GQUwQ

You know Blackjack. Also, referred to as 21.

In this game, you play against the dealer. You are both dealt hands and you can Hit or Stay based on the knowledge of your cards and the one card you can see of the dealers.

Welcome to Las Vegas or Atlantic City!! We are going to bring that to your Terminal 🙂

The source code for this program can be found here on Github https://github.com/techBytesIO/python_command_line

Other cool coding and tech things can be found here https://techbytes.io/

The Python programming language can be found here https://www.python.org/

Winner, Winner, Chicken Dinner!! 🙂

Source: YouTube

Share this video:
Code a Game of Blackjack with Python

10 thoughts on “Code a Game of Blackjack with Python

  1. This isn't actual blackjack. The dealer is supposed to keep hitting until at least 16, and even on 16 if the soft 16 rule applies.

  2. you should add a card deck like this it adds more realistic feel to the game

    from random import shuffle
    cardDeck=[]
    for j in ("Hearts", "Diamonds", "Spades", "Clubs"):
    for i in ("2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace"):
    cardDeck.append("%s of %s"%(i, j))
    shuffle(cardDeck)
    print(cardDeck)

  3. You are not using deck of cards and when drawn each card goes out of that deck, so you can draw same card all over again, dealer has 0 actions in this game, when you have blackjack there is possibility dealer also have one

  4. import random

    card_deck =[2,3,4,5,6,7,8,9,10,10,10,10,11] * 4
    print("———————–")
    print("—–Black Jack——–")
    print("Would you take a card? [y]-yes [n] – no")
    count = 0
    comp_count = 0

    while True:
    select = input ("Your select: ")
    if select =="y":
    current_card = card_deck.pop()
    print(f"Your card is: {current_card}")
    count += current_card
    if count > 21:
    print("You lOSE!")
    print(f"Total score: {count}")
    break
    elif count == 21:
    print("You Win!")
    print(f"Total score : {count}")
    break
    else:
    print(f"Total score:{count}")
    elif select =="n":
    print(f"Stop.Total score: {count}")
    break

    print("————Game Over——–")
    for i in range(2):
    comp_count = random.choice("234567891010 10 10 11")

    print(f"Computer – {comp_count}")

Comments are closed.