Learn Blackjack Video Source & Info:
Hey everyone, in today’s video we create blackjack in python. This is a beginner friendly tutorial where I walk you through every line of code you need to create blackjack. Creating this program reinforces all the beginner programming concepts (variables, loops, functions, print, input, etc.) and is incredibly simple to code.
On this channel we focus on all things Python. Whether it is a project tutorial/showcase, teaching different Python concepts, or just live coding this is one of the best channels for programmers. Check out my links down below 👇
Links:
Patreon: https://www.patreon.com/codecoach
Github: https://github.com/watsojar
Source: YouTube
I started on my own for a bit then came back to see if I was on the right track, and I was COMPLETELY wrong (I did the deck wrong and my solution for the face card were just off). I really wanna know how to think like this. How to think like a programmer. I would have never come up with this if I had to to it by my self.
Edit: like how did you think of the "21 – total(dealer_hand) > 21 – total(player_hand)" line. I still can't wrap my head around how you found that out.
I think you need to re-work your 'total' function. Sometimes it'll falsely claim a player has gone bust even if they haven't, at least in my experience.
Try something along the following:
def determine_total(hand):
total = 0
ace_11s = 0
for card in hand:
if card in range(11):
total += card
elif card in ['J', 'K', 'Q']:
total += 10
else:
total += 11
ace_11s += 1
while ace_11s and total > 21:
total -= 10
ace_11s -= 1
return total
This worked 100% accurately for me.
great video again thanks my man!
I like your voice and speaking,
Professional and comfortable.
Thank you
Hey @CodeCoach could you pls list down the code? It's not in the link in the description. Thx so much(I'm subscribed btw)!
make sure you include an else statement at the end to take care of when your hands tie.
Cozmo can play Blackjack
https://youtu.be/nHZlXpjtXME
I didn’t work for and I just wasted 3 hours bruh
It is counting ace as 11 for me? I need help
I tried on my own for a couple of hours , I feel very dumb after seeing you do it. My first project btw.