# Import libraries import random import time #Card values ace_1 = 0 ace_2 = 0 ace_3 = 0 ace_4 = 0 ace_5 = 0 total = 0 draw_choice = " " print("Welcome to 21!") time.sleep(1) while True: player_name = input("What is your name? ") if player_name.isalpha() == True: break else: print("Please enter a string input. ") time.sleep(1) print("Lets start") time.sleep(0.5) first_card_in_hand = random.randint(1, 13) time.sleep(0.5) if first_card_in_hand == 1 : print("You drawed an ace") ace_1 = str(input("Would you like your ace to be worth [1] or [11]? ")) if ace_1 == 11 : total + ace_1 if ace_1 == 1 : total + ace_1 else : ace_1 == 1 print("You didnt choose correctly, it's now a one") total + ace_1 if first_card_in_hand == 11 : print("You drawed a jack") time.sleep(0.5) if first_card_in_hand == 12 : print("You drawed a queen") time.sleep(0.5) if first_card_in_hand == 13 : print("You drawed a king") time.sleep(0.5) else : print("You drawed a {}".format(first_card_in_hand)) total = total + first_card_in_hand time.sleep(0.5) if total == 21 : print("CONGRATS YOU WON!") exit() if total >= 21 : print("YOU LOST") exit() else : print("Would you like to draw another card?") print("[yes] draw") print("or") print("[no] dont draw") draw_choice = input("Your choice... ") print() if draw_choice == "yes" : time.sleep(0.5) third_card_in_hand = random.randint(1, 13) if third_card_in_hand == 1 : print("You drawed an ace") ace_3 = input("Would you like your ace to be worth [1] or [11]? ") + ace_3 if ace_3 == 11 : total = total + ace_3 if ace_3 == 1 : total = total + ace_3 else : ace_3 == 1 print("You didnt choose correctly, it's now a one") total = total + ace_3 if third_card_in_hand == 11 : print("You drawed a jack") total = total + third_card_in_hand time.sleep(0.5) if third_card_in_hand == 12 : print("You drawed a queen") total = total + third_card_in_hand time.sleep(0.5) if third_card_in_hand == 13 : print("You drawed a king") total = total + third_card_in_hand time.sleep(0.5) else : print("You drawed a {}".format(third_card_in_hand)) total = total + third_card_in_hand print("Which is a combined total of", total) time.sleep(0.5) if total == 21 : print("CONGRATS YOU WON!") exit() if total >= 21 : print("YOU LOST") exit() else : print("Would you like to draw another card? [yes] or [no] ") print("[yes] draw") print("or") print("[no] dont draw") draw_choice = input("Your choice... ") print() if draw_choice == "yes" : time.sleep(0.5) fourth_card_in_hand = random.randint(1, 13) print("You drawed a {}".format(fourth_card_in_hand)) total = total + fourth_card_in_hand print("Which is a combined total of", total) time.sleep(0.5) if total == 21 : print("CONGRATS YOU WON!") exit() if total >= 21 : print("YOU LOST") exit() else : print("Would you like to draw another card? [yes] or [no] ") print("[yes] draw") print("or") print("[no] dont draw") draw_choice = input("Your choice... ") print() if draw_choice == "yes" : time.sleep(0.5) fifth_card_in_hand = random.randint(1, 13) if fifth_card_in_hand == 1 : print("You drawed an ace") ace_5 = input("Would you like your ace to be worth [1] or [11]? ") + ace_5 if ace_5 == 11 : total = total + ace_5 if ace_5 == 1 : total = total + ace_5 else : ace_5 == 1 print("You didnt choose correctly, it's now a one") total = total + ace_5 if fifth_card_in_hand == 11 : print("You drawed a jack") total = total + fifth_card_in_hand print("Which is a combined total of", total) time.sleep(0.5) if fifth_card_in_hand == 12 : print("You drawed a queen") total = total + fifth_card_in_hand print("Which is a combined total of", total) time.sleep(0.5) if fifth_card_in_hand == 13 : print("You drawed a king") total = total + fifth_card_in_hand print("Which is a combined total of", total) time.sleep(0.5) else : print("You drawed a {}".format(fifth_card_in_hand)) total = total + fifth_card_in_hand print("Which is a combined total of", total) time.sleep(0.5) if total == 21 : print("CONGRATS YOU WON!") exit() if total >= 21 : print("YOU LOST") exit() else : print("hi")