deck of 52 cards ============================ x = 26 cards y = 26 cards while x has cards and y has cards x and y turn over card if y's card is higher than x, y takes them if x's card is higher than y, x takes them if cards are the same, each takes back their own card ============================= deck = [ "AS", ... , "2C" ] # return True if xcard > ycard # return False if xcard < ycard def higher(xcard, ycard): xnum = deck.find(xcard) ynum = deck.find(ycard) if xnum > ynum: return True if ynum > xnum: return False print("Cards are equal! xcard =", xcard, "ycard =", ycard) sys.exit(0) # shuffle deck and deal usedeck = deck random.shuffle(usedeck) x = usedeck[:26] y = usedeck[26:] # play while len(x) > 0 and len(y) > 0: print(x[0], "vs.", y[0]) if higher(x[0], y[0]): add y[0] to the end of x's list delete y[0] from y's list if higher(y[0], x[0]): add x[0] to the end of y's list delete x[0] from x's list