I'm making a blackjack game as a beginners project. I'm having trouble with exiting multiple loops. Instead of exiting the blackjack game and stopping the program that's running when the input is "Leave" the loop continues.
This is the part of my code that I'm having problems with.
def deal_cards():
while deck != []:
# code here that's irrelevant
while player_sum <= 21:
if player_sum == 21:
print('BLACKJACK!')
break
move = input('What would you like to do: ') # this is the player input. When the input is
if move == 'Hit' or move == 'hit' or move == 'HIT' or move == 'HIt' or move == 'hIt':
card = random.choice(deck)
deck.remove(card)
player_sum = player_sum + card
print('You got a ' + str(card) + '. Your sum is ' + str(player_sum))
if player_sum > 21:
print("YOU BUSTED")
break
elif move == 'Stand' or 'stand' or 'STAND':
print('The dealer has: ' + str(dealer_sum))
while dealer_sum < 17:
card = random.choice(deck)
deck.remove(card)
dealer_sum = dealer_sum + card
print('The dealer has: ' + str(dealer_sum))
if dealer_sum > player_sum and dealer_sum <= 21:
print('You lost')
elif dealer_sum == player_sum:
print('Even. You get you money back')
elif dealer_sum < player_sum:
print('YOU WIN!')
elif dealer_sum > 21:
print('The dealer busted. YOU WIN!')
break
if move == 'Leave' or 'leave' or 'LEAVE': # this is where the
# problem is. I want the entire program to end. I tried using break and
# return but I don't seem to get it wotking.
welcome_screen()