Advanced Python: Uno

Today we'll be exercising our advanced Python skills, assuming familiarity with functions, data structures like arrays, tuples and dictionaries, and classes. An easier version of the game can be employed without classes and if you prefer, you can start with that and then consider what properties and functions can be grouped under a class. You can also go beyond and use a GUI, mouse presses, buttons, animations, etc. 

The Game 

Uno is a card game with a simple goal: get rid of your hand first! You can play any hand that matches either the color or the number/type of the card in the middle.

There are four colors (red, blue, green, yellow) and each has 2 of the following types of cards:

There are 8 other interesting cards, colored black, and can be put on the deck regardless of the color/number of the middle card:

If you have no possible hand to play, you can draw a card from the deck and play if you get one.

You can read more about the game:

The Task

So with these instructions in mind, you can creatively code the game using simple print statements to display the middle card, the cards of the player, the cards the computer has left, the winner, etc by showing the color and number/type of card. You can use classes and functions to make it easier and how you use them can vary from another person's implementation. To recap classes:

class Card:
    def __init__(self, color, type):
        self.color = color
        self.type = type 

Some possible classes and functions you can implement:

You have creative freedom, these are just suggestions. You may want to have functions outside of classes, in the general gameplay code or main. You might use a loop instead of a function to move the game. Experiment with different things, using arrays or some other structure to save the deck. 

Example Output

It is your turn!
The middle card is a ['RED', 1]
Your hand contains the following cards: 
Card #1:   ['BLUE', 3]
Card #2:   ['YELLOW', 1]
Card #3:   ['BLUE', 8]
Card #4:   ['RED', 7]
Card #5:   ['WILD', '+4']
Card #6:   ['RED', '+2']
Card #7:   ['GREEN', 8]
Type 1 to play card #1
Type 2 to play card #2
Type 3 to play card #3
Type 4 to play card #4
Type 5 to play card #5
Type 6 to play card #6
Type 7 to play card #7
Type DRAW to draw a card (it ends your turn).