According to my understanding when I should run the the while loop in the main body and calls the hit_or_stand(deck,hand) function, the code should run indefinitely times around the while loop(in the function) when I choose h but to my surprise the following code run in the following way:
1- Asks for h or s ?
I type h
2- show_some(player_hand,dealer_hand)
3-if player_hand.value > 21:
player_busts(player_hand,dealer_hand,player_chips)
break
Do not you think the code should run indefinitely around 1st step as I am always choosing h and to my understanding it should remain in the loop of hit_or_stand() function.
def hit_or_stand(deck,hand):
global playing
while True:
x = input("Would you like stand or hit? Enter 'h' or 's'")
if x[0].lower() == 'h':
hit(deck,hand)
elif x[0].lower() == 's':
print("player stands. Dealer is playing. ")
playing = False
else:
print("Sorry, please try again.")
continue
break
Main Body
while playing: # recall this variable from our hit_or_stand function
hit_or_stand(deck,player_hand)
show_some(player_hand,dealer_hand)
#if player hand exceeds 21, run player busts() and break out of the loop
if player_hand.value > 21:
player_busts(player_hand,dealer_hand,player_chips)
break