Debugging in Python, part 11: Another logical error
MP 154: They just keep coming. :)
Note: This post is part of an ongoing series about debugging in Python. The posts in this series will only be available to paid subscribers for the first 6 weeks. After that they will be available to everyone. Thank you to everyone who supports my ongoing work on Mostly Python.
In the last post, we started implementing a Go Fish game. We ran into a logical error when dealing hands, but that error was corrected by the end of the post. In this post we'll get into actual game play.
The code for this post picks up from here, after implementing the fix for all hands pointing to the same list of cards. If you want to follow along, you can make a copy of that folder and make changes from that point.
Letting the player guess
When you run go_fish.py currently, all it does is deal two hands:
$ python go_fish.py Player hand: 2♠ 3♣ 3♥ 6♥ 10♥ Q♦ A♠ Computer hand: X X X X X X X
There are a number of ways we could start implementing game play. We'll need to address any pairs each player starts with, but I'd rather start with the interactive game play. I'll first write code that lets the player take a turn. At this point in the project, we'll assume the human player always goes first.
We already have a player_turn() method that shows the current state of the game. Let's implement the player's turn in that method for now:
This post is only available to paid subscribers at the moment. It will be available to everyone 6 weeks after posting. If you'd like to continue reading now, please support my work by signing up for a paid subscription.