import random


n = 52
Black, Red = 'Black', 'Red'
blacks = [Black] * (n 
reds = [Red] * (n 
pack = blacks + reds

random.shuffle(pack)


black_stack, red_stack, discard = [], [], []
while pack:
    top = pack.pop()
    if top == Black:
        black_stack.append(pack.pop())
    else:
        red_stack.append(pack.pop())
    discard.append(top)
print('(Discards:', ' '.join(d[0] for d in discard), ')\n')



max_swaps = min(len(black_stack), len(red_stack))

swap_count = random.randint(0, max_swaps)
print('Swapping', swap_count)

def random_partition(stack, count):
    
    sample = random.sample(stack, count)
    rest = stack[::]
    for card in sample:
        rest.remove(card)
    return rest, sample

black_stack, black_swap = random_partition(black_stack, swap_count)
red_stack, red_swap = random_partition(red_stack, swap_count)


black_stack += red_swap
red_stack += black_swap


if black_stack.count(Black) == red_stack.count(Red):
    print('Yeha! The mathematicians assertion is correct.')
else:
    print('Whoops - The mathematicians (or my card manipulations) are flakey')