+ 1

How do I make the cards split randomly from the list and then be deleted from it?

Help me with this card game

14th Apr 2018, 5:30 AM
Raphael Shay
Raphael Shay - avatar
3 ответов
+ 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
14th Apr 2018, 6:20 AM
Obbu
Obbu - avatar
+ 1
Is there any other "more basic" way to do it?
14th Apr 2018, 6:30 AM
Raphael Shay
Raphael Shay - avatar
+ 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
14th Apr 2018, 6:36 AM
Obbu
Obbu - avatar