简体   繁体   中英

Hey lads, kinda new to doing Python and was thinking for a bit about this

So, I tried to create a basic fundamental code for a "hit" option in Blackjack. There were like two other more complex versions and this is the most simple I've gotten. Does this suffice or am I missing some specific statistics jargon that makes this innacurate?

import random

valLi= ["two","three", "four", "five","six", "seven", "eight", "nine","ten", "king", "queen","ace", "jack", "two","three", "four", "five","six", "seven", "eight", "nine","ten", "king", "queen","ace", "jack", "two","three", "four", "five","six", "seven", "eight", "nine","ten", "king", "queen","ace", "jack", "two","three", "four", "five","six", "seven", "eight", "nine","ten", "king", "queen","ace", "jack" ]
random.shuffle(valLi)
random.sample(valLi, len(valLi))


while True:
    if input() == "h":
        print(valLi[0])
        print(valLi)
        del valLi[0]
import random

valLi= ["two","three", "four", "five","six", "seven", "eight", "nine","ten", "king", "queen","ace"] * 4
random.shuffle(valLi)

def deal(deck):
    return deck.pop(0)

while True:
    if input() == "h":
        c1 = deal(valLi)
        c2 = deal(valLi)
        print( c1, c2 )

The problem with this structure, of course, is that it makes it hard for you to compute the value of the hand. You will probably want to use a different data structure for the point values.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM