def is_straight(hand, numwildcards=0):
    """Checks for a five card straight

    Inputs: list of non-wildcards plus wildcard count
        2,3,4, ... 10, 11 for Jack, 12 for Queen,
        13 for King, 14 for Ace
        Hand can be any length (i.e. it works for seven card games).

    Outputs:  highest card in a five card straight
              or 0 if not a straight.
        Original list is not mutated.
        Ace can also be a low card (i.e. A2345).

    >>> is_straight([14,2,3,4,5])
    5
    >>> is_straight([14,2,3,4,6])
    0
    >>> is_straight([10,11,12,13,14])
    14
    >>> is_straight([2,3,5], 2)
    6
    >>> is_straight([], 5)
    14
    >>> is_straight([2,4,6,8,10], 3)
    12
    >>> is_straight([2,4,4,5,5], 2)
    6
    """

    hand = set(hand)
    if 14 in hand:
        hand.add(1)
    for low in (10,9,8,7,6,5,4,3,2,1):
        needed = set(range(low, low+5))
        if len(needed - hand) <= numwildcards:
            return low+4
    return 0
Checks for a five card straight

    Inputs: list of non-wildcards plus wildcard count
        2,3,4, ... 10, 11 for Jack, 12 for Queen,
        13 for King, 14 for Ace
        Hand can be any length (i.e. it works for seven card games).

    Outputs:  highest card in a five card straight
              or 0 if not a straight.
        Original list is not mutated.
        Ace can also be a low card (i.e. A2345).

    >>> is_straight([14,2,3,4,5])
    5
    >>> is_straight([14,2,3,4,6])
    0
    >>> is_straight([10,11,12,13,14])
    14
    >>> is_straight([2,3,5], 2)
    6
    >>> is_straight([], 5)
    14
    >>> is_straight([2,4,6,8,10], 3)
    12
    >>> is_straight([2,4,4,5,5], 2)
    6
    
recipes/Python/415504_Poker_hand_primitives/recipe-415504.py