I am very new to python and have been trying for some time to make multi-user blackjack in python. I came across a lot of problems and wondered if you guys could help me with them.
import random
def total(hand):
aces = hand.count(11)
t = sum(hand)
if t > 21 and aces > 0:
while aces > 0 and t > 21:
t -= 10
aces -= 1
return t
Cards = ["2H", "3H", "4H", "5H", "6H", "7H", "8H", "9H", "2C", "3C", "4C", "5C", "6C", "7C", "8C", "9C", "10C", "2S", "3S", "4S", "5S", "6S", "7S", "8S", "9S", "10S", "2D", "3D", "4D", "5D", "6D", "7D", "8D", "9D", "10D", "AH", "JH", "QH", "KH", "AC", "JC", "QC", "KC", "AS", "JS", "QS", "KS", "AD", "JD", "QD", "KD"]
Cards[35] = 11
Cards[36] = 10
Cards[37] = 10
Cards[38] = 10
Cards[39] = 11
Cards[40] = 10
Cards[41] = 10
Cards[42] = 10
Cards[43] = 11
Cards[44] = 10
Cards[45] = 10
Cards[46] = 10
Cards[47] = 11
Cards[48] = 10
Cards[49] = 10
Cards[50] = 10
Players = raw_input("How many players are there?")
for i in range Players:
Player i = []
Player i.append(choice(Cards))
Player i.append(choice(Cards))
tp = total(player)
print "Player" + i + "Cards: " + Player i + "," + "total: " + tp
hitorstand = raw_input("hit (h) or stand (s)?")
if hitorstand == "h":
Player i.append(choice(cards))
print ("hit (h) or stand (s)?")
elif hitorstand == "s":
break
else print "Please enter h or s"
dealer = []
While True:
dealer.append(choice(cards))
dealer.append(choice(cards))
td = total(dealer)
while td > 17:
dealer.append(choice(cards))
else:
break
if td < tp < 21:
"Player i wins"
else print "dealer wins"
This is what I still have. I understand that there is a lot of gibberish and code that won't work. I was wondering if you guys can tell me what is wrong with the code, and maybe suggest some options for how to fix it.
My main problems right now:
I am doing multi-player blackjack. I have no idea how I should make a loop for a multiplayer blackjack game. In my code, I asked how many people are playing. How to create a cycle for the game, not knowing what the number will be?
, , , , ?
Players = raw_input("How many players are there?")
for i in range Players:
Players for . ?
, ,
,
, .
, , , . , ,
playerlist = [1,2,3]
if playerlist[0] > playerlist[1], playerlist[2] and playerlist[0] < 21:
then print "player 1 wins!"
, , , , .
, " , ". , " , ".
" , " python?
, , ?