I am a beginner with Python.
I have been struggling with creating a proper list comprehension for my deck of cards. I want to create four lists within a list where each "number index" has the fitting type. I'll try to show below.
This is what I want:
deck = [["1 Hearts, "2H", ..."13H"], ["1 Diamonds", "2D", ..."13D"], [....], [...]]
This is what I have:
value = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"]
deck_types = ["hearts", "diamonds", "clubs", "spades"]
deck = [[i] + value for i in deck_types]
Output:
I can't post images because my reputation is below 10, but I will describe it.
[["hearts", "1", "2", "3"....], ["Diamonds", "1", "2", "3"....], ["Clubs", "1"...], [....]]
As you can see, it's not exactly what I want. Each type becomes the nr [0] in every sublist. My plan is to combine the .pop() function with random.randint for card draw. So that when the first player draws a card, that card will be removed from the deck. Then the second player will not be able to draw the same card. When I then print the first players' card, I want to be able to see both type and number. Thus far I have only been able to see the number.
Like this:
card1 = deck[random.randint(1, 3)].pop(random.randint(2, 13))
card2 = deck[random.randint(1, 3)].pop(random.randint(2, 13))