I have written a program that randomly generates a hand consisting of two cards. I want it to generate hands until certain combinations occur eg. a pair or a premium hand such as AK, AQ or KQ.
I have already covered the possibility of a pair being drawn (this was fairly straightforward). I also want it to stop the while loop when suited connectors occur; eg. 98 suited or 65 suited. How could I assign a value to each card in order to do this?
def generateHand():
pair = False
while playables == False:
first_rank = random.choice(('A','2','3','4','5','6','7','8','9','T','J','Q','K'))
print(first_rank)
first_suit = random.choice(('d','c','h','s'))
second_rank = random.choice(('A','2','3','4','5','6','7','8','9','T','J','Q','K'))
print(second_rank)
second_suit = random.choice(('d','c','h','s'))
isSuited = 'o'
if first_suit == second_suit:
isSuited = 's'
print isSuited
print(' ')
if first_rank == second_rank:
playable = True