so long story short:
import random
cards = [11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10]
user_hand = []
computer_hand = []
def draw(x):
for c in range(0, x):
card = random.choice(cards)
return card
user_hand.append(draw(1))
print(user_hand)
Trying to get a function together that will loop through the cards list and pick a random item, however many times as specified by X, however no matter the number plugged into
user_hand.append(draw(x))
it always returns only 1 card, quite stumped. Any ideas? Thought it was the return in the function as return ends a code block when it's called but i wasn't sure.
user_hand.append(random.choice(cards))instead ofcard = random.choice(cards). Then call draw(x) without to append part. However, this will draw cards with replacement, I am not sure if this is what you want to do.