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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.