"""
Ch8 Q5(f)
Monte Carlo card game
Straigt
"""



hand = ['CT', 'HJ', 'HQ', 'HK', 'CA']
print(hand)

def straight(hand):
    rank = ["A","2","3","4","5","6","7","8","9","T","J","Q","K"]
    straight = False

    #check for straight
    order = [] #Start a list to store numerical values of the cards
    for i in range(0,len(hand)):
        order.append(rank.index(hand[i][1])) #list.index() tells the location in the list
        order.sort() #sort the list in an asending order
        
    if order[4]-order[3]==1 & order[3]-order[2]==1 & order[2]-order[1]==1 & order[1]-order[0]==1:
        straight = True   #This takes care of any ordinary straight
    if order[0]==0 & order[4]==12 & order[3]==11 & order[2]==10 & order[1]==9:
        straight = True  #This takes care of AKQJT
            
            
    return straight
    
print(straight(hand))
        




            

