jeudi 26 mai 2016

Python 3 How to move an item from list x to list y and remove it from list x?

Quick question I am trying to add .append a random card from list x (in this case is Deck = []) and move it into list y (in this case is MyHand = []). Then I want to remove the item from list that was added into list y.

import random
Deck = []
MyHand = []
CardsPicked = 0
for Cards in range(1, 101):
    Deck.append(Cards)
print(Deck)
while(CardsPicked < 8):
    MyHand.append(random.choice(Deck))
    CardsPicked = CardsPicked + 1
print(MyHand)

THINGS TO KNOW: I have the moving one card from list x into list z but i can't remove the card that was moved into list y from list x.

I tried doing:

Deck.remove(random.choice)

But it said that the choice wasn't in the deck




Aucun commentaire:

Enregistrer un commentaire