I have a list and I want to assign a random element from that list to a new variable five times in order to generate a hand of cards. I've searched, and I can't seem to understand why my random.choice is causing errors.
import random
cards = { '2' '3' '4' '5' '6' '7' '8' '9' 'J' 'Q' 'K' 'A' }
for newCard in range(5):
newDraw = random.choice(cards)
playerdeck.append(newDraw)
if newDraw in playerdeck:
playermatches = playermatches + 1
newDraw = oldDraw
When I try to run it I get this error:
Traceback (most recent call last):
File "C:\Users\Nathaniel\Desktop\Fcard.py", line 6, in <module>
newDraw = random.choice(cards)
File "C:\Python32\lib\random.py", line 253, in choice
return seq[i]
TypeError: 'set' object does not support indexing