I wrote the first version of this game before Python had the Enum class. Here I show how I improved the code to use this one:
class Item(Enum):
ROCK = 0
PAPER = 1
SCISSORS = 2
https://github.com/dcbriccetti/python-lessons/commit/f5db0cf800f742570629c2862dd4bb34258b5979
Oops. The comment for the beats function,
'Return the item this item beats'
is out of date. It should say,
'Return whether this item beats the given item'.
Download
0 formats
No download links available.
Python Enum: Refactoring Rock, Paper, Scissors Game | NatokHD