I am trying to make a card game and I want to be able to generate random numbers in a list but I do not want the numbers to repeat themselves after they have been used once while the program is running.
Here is what I have so far:
usedcards = []
import random
def choosecards():
global usedcards
cards=random.sample(range(52), 5)
usedcards = usedcards + cards
#print(usedcards)
return cards
Each time I run the function, I want the usedcards list to be cross checked with the cards variable.
How can I make this happen?
random.shuffle()) and.pop()a card when you need one.