Question: Show me the steps to solve Create a function called compare _ hands ( agent _ hand, dealer _ hand ) that does the following:

Show me the steps to solve
Create a function called compare_hands(agent_hand, dealer_hand) that does the following:
Accepts 2 parameters:
agent_hand of type list that represents the cards in the agents hand
dealer_hand of type list that represents the cards in the dealer's hand
Determine the winner based on these rules:
If the agent_hand value is over 21, the player busts, and the dealer wins.
If the dealer_hand value is over 21, the dealer busts, and the player wins.
If the agent_hand value is higher than the dealers, the player wins.
If the dealer_hand value is higher than the players, the dealer wins.
If both have the same value, its a push (a tie).
Returns the result of the comparison as a string (e.g.Player busts!).
Replace your existing main function from the previous parts with one that does the following:
Prompts the user to enter a filename.
Call the read_deck function with filename as an argument to obtain the deck_of_cards.
Call the shuffle function with deck_of_cards as an argument to obtain shuffled_deck.
Uses a while statement to repeatedly play the game until the number of cards left in the shuffled_deck is less than or equal to 10. Each iteration of the loop should follow these steps:
Initialization
Call the deal_card function with shuffled_deck and number_of_cards as arguments to obtain agent_hand. Set number_of_cards to 2 to give the agent an initial hand of 2 cards.
Call the deal_card function with shuffled_deck and number_of_cards as arguments to obtain dealer_hand. Set number_of_cards to 2 to give the dealer an initial hand of 2 cards.
Play Hands
Call the play_hand function with agent_hand and shuffled_deck as arguments to update agent_hand.
Call the play_hand function with dealer_hand and shuffled_deck as arguments to update dealer_hand.
Compare Hands
Call the compare_hands function with agent_hand and dealer_hand as arguments to obtain the result of the game.
Print the result of compare_hands.
Sample output
Enter filename: deck1.txt
Dealer busts!
Dealer wins!
Dealer busts!
Dealer busts!
Player wins!
Player busts!
Dealer busts!
Push!

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!