00:01
Hello, for problem 22, you are going to be choosing cards until you get one card of every suit.
00:14
And then once you do that, you want to display the cards as well as how many picks you needed to make in order to get all four suits.
00:27
So in order to pick cards, i'm going to be.
00:30
Use the random so i'll start by importing random and then instead of setting up a deck of cards i separated out rank and suit so rank here is just the a list including all of the ranks of cards in a typical deck and then suit is a list with all of the suits for those cards i'm going to start two empty lists one for cards and one for card suits just to make it easy to check whether or not we've gotten all four card suits.
01:08
I'm also going to start two counters.
01:11
One is n, which is the number of suits, and one which is p, which is the number of picks that we've made.
01:20
So both of those will start with zero.
01:23
And we're going to use a while loop.
01:26
So while the number of suits is less than four, because we want all four suits.
01:32
While the number of suits is less than four, we're going to choose a card at random.
01:37
So card rank will be random .choice rank and card suit will be random.
01:44
Choice of suit.
01:45
If card suit is in our list of card suits, then we know that it's not really helpful to us because it's a repeat suit.
01:58
So we'll increase our pick number because we've picked another card, but you could just not leave anything, but with while loops, i think that it's really important to make sure that the counter that the while is working on is being updated regularly...