I have the following in code; which I forgot where I got it or what's it called (I'm new to Python):
deck = [Card(x, y) for x in cards for y in suits]
From the above code, I am trying to create multiple decks into a list, so that the user inputs the number of decks. I have been trying to do it like this:
decks = 2
i = 0
while i < decks:
deck = [Card(x, y) for x in cards for y in suits]
i += 1
But that just overwrites the current deck variable. I also tried:
decks = 2
deck = []
i = 0
while i < decks:
deck.append(Card(x, y) for x in cards for y in suits)
i += 1
But I only get <generator object <genexpr> at 0x04562C30> and <generator object <genexpr> at 0x04562BF0> as output when I print the contents of the deck. How exactly do I achieve what I want and how do the two for loops work in the creation of the list?
I tried the following to iterate over the members of the list; doesn't work:
for x in deck:
for j in x:
print(str(deck[x][j]))
deck.append([...])?