Go Fish, Part I: Draw a Card from a Deck
This function draws a card from a deck and puts it into a hand. It is meant to be a part of the game Go Fish, so if the resulting hand has all four suits for a given card rank, those four cards are removed from the hand. The next two programs build on this one to produce a full version of the game.
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", "J", "Q", "K", "A"] and the suit is one of the elements of the list ["spades", "hearts", "diamonds", "clubs"].
A deck is a list that initially contains 52 elements. Each element ...
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.