Question: Create a deck. Give each player two cards ( chosen randomly using random.choice ) . Display both hands Prompt the player to either hit (

Create a deck.
Give each player two cards (chosen randomly using random.choice).
Display both hands
Prompt the player to either hit (that is, draw another card) or stay.
If the player hits, keep checking whether the total value of the players cards is equal to 21. If it is, then the player wins, and if it is above 21, then the player loses. Display each updated hand after each card draw.
If the player stays, then its the dealers turn to act. If the total value in the dealers hand is less than 17, then they must hit. If it is greater than or equal to 17 but less than or equal to 21, then the dealer must stay. If at any time the dealers total value is above 21, then the dealer busts and the player wins.
Finally, if both the player and dealer scores are below 21, and no one has busted yet, the player with the highest total wins. In the case of a tie, the dealer wins.

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 Programming Questions!