import numpy as np
values = ['2','3','4','5','6','7','8','9','10','J','K','Q','A'] suits = ['H','D','S','C'] cards = [[v,s] for v in values for s in suits]
def pair(): np.random.shuffle(cards) pair_counter = 0 cards_counter = 0 values = [] for card in cards: value = card[0] cards_counter +=1 if not value in values: values.append(value) if len(values) ==4: pair_counter +=1 if pair_counter == 1: return cards_counter
pair()
The expected amount of cards are 4 in order to get two cards with the same value.