Go Fish, Part II: Ask if Another Hand Has a Card

This function constitutes another component of the Python version of Go Fish. This function checks if the other player has any cards of a specified rank, and if so, it transfers them to the player's hand. If this results in the player having all four cards of that rank, the cards are deleted from the player's hand.

Here's a quick recap of the relevant definitions from the previous example (this function only concerns itself with hands; it does not use the deck):

  • Cards are identified by their rank and suit: The rank is one of the elements of the list ["2", "3", "4", "5", "6", "7", "8", "9", "10", ...

Get Find the Bug A Book of Incorrect Programs now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.