+ 1
How do I make the cards split randomly from the list and then be deleted from it?
Help me with this card game
3 Answers
+ 1
well you can do it this way (its the most compact way i could think of)
from random import shuffle
list = (the card names)
shuffle(list)
a = [x[i] for i in range(len(x)) if i%2 == 0]
b = [x[i] for i in range(len(x)) if i%2 != 0]
unless you need the list just delete it after
+ 1
Is there any other "more basic" way to do it?
+ 1
there are but they are alot longer
if you dont get the sorting bits you can do this
a = []
for i in range(len(list)):
if i %2 == 0:
a.append(list[i])
list.remove(i)
and then your left with half in a and the other half in list