repl.it
@CarterMonkey/

Blackjack2

Python

Boiiiiii

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import random

dhand = []
phand = []
deck = []
faces = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K']

for i in range(4):
  for face in faces:
    deck.append(face)

random.shuffle(deck)

def startGame():
  phand.append(deck.pop(0))
  dhand.append(deck.pop(0))
  phand.append(deck.pop(0))
  dhand.append(deck.pop(0))

  print ("Your hand is " + str(phand))
  print ("Dealer hand is " + str(dhand[0]) + " UNKNOWN")

def calculatePoints(hand):
  numbAces = 0
  points = 0
  for card in hand:
    if (card == 'A'):
      numbAces +=1
    else:
      if (faces.index(card) < 10):
        points += faces.index(card) + 1
      else:
        points += 10