Another modify task, and this time the random thing is not a number but an item from a list.
The editor starts you off with a program that draws one playing card:
import random
card_values = ["Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"]
card = random.choice(card_values)
print("You drew the " + card)
Run it a few times. It picks one of the thirteen values at random, but a real card has a suit as well, and a real hand has more than one card.
Change the program so that:
Some details, so that your program can be checked automatically:
suits = ["Hearts", "Diamonds", "Clubs", "Spades"]
Leave card_values exactly as it is.
random.choice.Five lines, one for each card as it is drawn, where VALUE is the value and
SUIT is the suit:
You drew the VALUE of SUIT
Then one more line: the whole list of five cards, printed in one go, with its square brackets, quotes and commas.
The cards are random, so your program will draw a different hand every time you run it. This is one possible run:
Output:
You drew the Three of Hearts
You drew the Five of Hearts
You drew the Eight of Spades
You drew the Eight of Spades
You drew the King of Diamonds
['Three of Hearts', 'Five of Hearts', 'Eight of Spades', 'Eight of Spades', 'King of Diamonds']
The Eight of Spades comes up twice. That is allowed: random.choice does not
take anything out of the list, so every card is drawn from a full deck.
How can a random program be checked?
The checks fix the random seed before your program runs, so they know which cards it is going to draw. That only works if your program asks for random items in the same order as the checks expect: first a value, then a suit, five times over. Pick the suit first and your hand comes out different, even though there is nothing wrong with it as a game.
Make sure that you check for the following things:
"Hearts", "Diamonds", "Clubs", "Spades", in that
order, with capital letters.[].append.of come from inside the speech marks: " of ".print of the list is not indented, so it runs once, after the loop.