I am getting an IndexError
and I'm unsure why.
cards = [2, 3, 4, 5, 6, 7, 8, 9, 10 ,11, 12, 13, 14,
2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
USER = []
CPU = []
selected = 1
while selected < 26:
CPU.append(cards.pop(random.choice(cards)))
USER.append(cards.pop(random.choice(cards)))
selected = selected + 1
I want the items inside the list cards
to be appended into the lists USER
and CPU
. It worked originally but after working on something else it stopped working. I looked up why but the pop
index says it's out of range, but I don't understand why.