Question: So for a project, I decided to write a blackjack game in python 3. I have tried many different methods for getting my code to

So for a project, I decided to write a blackjack game in python 3. I have tried many different methods for getting my code to work, but all of them failed. I decided to take the best ideas from all of the code i've written and apply them to this blackjack game, but I can't decide how to move forward. Specifically, I've really been struggling with the value_setter function below. Can anyone take a look at my code and give me some advice?

from random import shuffle

RANK = [_ for _ in range(2, 11)] + ['Jack', 'Queen', 'King', 'Ace'] SUIT = ['Spades', 'Hearts', 'Diamonds', 'Clubs']

def deck_of_cards(): deck_of_cards = [[ranks, suits] for ranks in RANK for suits in SUIT] shuffle(deck_of_cards) return deck_of_cards

deck = deck_of_cards()

def value_setter(card):

card[0] = RANK if RANK in ranks[0:-4]: count += int(rank) elif RANK is 'Ace': count += 11 elif RANK is 'Jack' or 'Queen' or 'King': count += 10

return count

def initial_hands(deck): player_hand = [] dealer_hand = [] while len(dealer_hand) < 2: player_hand.append(deck[0]) deck.pop(0) dealer_hand.append(deck[0]) deck.pop(0)

return [dealer_hand, player_hand]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!