I have been trying to shuffle a list in specific manner:
def shuffle(card_deck):
shuffled = list()
deck_size = len(card_deck) // 2
lhand_deck = card_deck[0: deck_size]
rhand_deck = card_deck[deck_size: deck_size*2]
for i, j in zip(lhand_deck, rhand_deck):
shuffled.append(i); shuffled.append(j)
return shuffled
To improve the perform for a larger deck, I decided to use list comprehension:
shuffled = [
i
for i in zip(lhand_deck, rhand_deck)
]
Now the the list contains tuple however I want it contain it single element:
shuffled = [0, 2, 1, 3]
instead of
shuffled = [(0,2), (1, 3)]
The * doesn't work it this case since it throws error. Is there any method to it or a loop can only be used? Thanks for help