Need Help With Invalid Syntax Error

import random
import time  # import time for time.sleep

from colorama import Fore, Style  # Used to color text

tele = False
# Determines the chance at the end to slip off or not
min = 1
max = 2
def randint(min, max):
    num = random.randint(1, 2)
    return num
NAMEE = input("Whats your name?")
print("\n *Flash back* ")
time.sleep(2)
print("/-------------------\\ ")
print("( Dear " + NAMEE + "            )")
print("(  We are sorry to  )")
print("(infrom you that you)")
print("(have been drafted  )")
print("(to war. We need you)")
print("( -USA Goverment    )")
print("\\-------------------/")
time.sleep(5)
print("\n *Pew* *Pew* ")
print("NOOOOOO")
print("\n *Goes into a deep coma* ")
time.sleep(5)
print(f"{Fore.GREEN}You wake up from your coma and realize you are stuck in a dungeon!{Style.RESET_ALL}")
print("[:::::=======:::::]")
print("[:::::( 0 0 ):::::]")
print("[:::::(  -  ):::::]")
print("[:::::( --- ):::::]")
print("[:::::=== ===:::::]")
print("[:::::::| |:::::::]")
print("[::::---| |---::::]")
print("[:::::::/ \\:::::::]")
print("   -(That's You)-   ")
print("You have to find a way out to survive.")
FOYOD = input("Do you want to 1. Yell for the guard 2. Flush yourself down the toilet or 3. disassemble the toilet: ")
if FOYOD == "1":
    print("You yell for the guard and he hears you.")
    print("Out of anger for waking him up from his nap he shoots you.")
    print("Gameover! Please start again")
elif FOYOD == "2":
    tele = True  # If FOYOD is 2, assigning True to tele
elif FOYOD == "3":
    print("You disassemble the toilet and find a key and a knife. Which one do you take?")
    KOK = input("1. Key 2. Knife: ")
    if KOK == "1":
        print("You pick up the key and realize it has a toxin in it. Later that day you die.")
        print("Gameover! Please start again")
    elif KOK == "2":
        print("You pick up the knife and you can do 2 things.")
        KYSOW = input("1. Stab yourself so you don't suffer or 2. stab the wall: ")
        if KYSOW == "1":
            print("You stab yourself and die. WHAT WERE YOU THINKING?!?!?!?!?!?!?!")
            print("Gameover! Please start again")
        elif KYSOW == "2":
            print(f"{Fore.RED}You stab the wall and it reveals a tunnel!{Fore.WHITE}")
            TON = input("Do you 1. Go into the tunnel or 2. stay in your cell: ")
            if TON == "2":
                print("You stay in your cell but the guard comes by and sees you with a knife. He then shoots you.")
                print("Gameover! Please start again")
            elif TON == "1" or tele:
                print("You flush yourself down the toilet and it reveals a tunnel")
                print("You go into the tunnel and it reveals two pathways.")
                LOO = input("Do you 1. Go left or 2. Go right: ")
                if LOO == "2":
                    print("You go right but another guard sees you and shoots you.")
                    print("Gameover! Please start again")
                elif LOO == "1":
                    print("You go left and you find a chest.")
                    print("You open the chest and find a cannon sword.")
                    PPP = input("Do you 1. Take the sword or 2. Leave the sword: ")
                    if PPP == "1":
                        print("You take the sword and you fight the guard.")
                        print("You fight the guard and you win!")
                    elif PPP == "2":
                        print("You leave the sword and you fight the guard.")
                        print("You lose badly. You get destroyed by his AK47.")
                        print("Gameover! Please start again")

if tele is True:
    print("You flush yourself down the toilet but more guards sees you")
FOR = input("Do you 1. Fight them or 2. Try to run away: ")
if FOR == "1":
    print("You attempt to fight back but you get shot.")
    print("GAMEOVER! Try again.")
elif FOR == "2":
    print("You run away and surprisingly don't get shot!")
    print("You see an opening in the dungeon and you begin to climb the wall.")
    JOS = input("Do you 1. grab the rock on the left or 2. the rock on the right: ")
    rand = randint(1, 2)
    if rand == 1 and JOS == "1" or rand == 2 and JOS == "2":
        time.sleep(2)
        print("...")
        print("You grab the rock and manage to slip out of the hole in the roof.")
        print("You run out of the area and escape!")
print("Before you leave another guard sees you.")
print("He tells you if you beat him in blackjack you can leave")
def create_deck():
    ranks = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']
    suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades']
    deck = [{'rank': rank, 'suit': suit} for rank in ranks for suit in suits]
    random.shuffle(deck)
    return deck
def calculate_score(cards):
    score = sum([11 if card['rank'] == 'A' else 10 if card['rank'] in ['K', 'Q', 'J'] else int(card['rank']) for card in cards])
    num_aces = sum([1 for card in cards if card['rank'] == 'A'])
    while score > 21 and num_aces:
        score -= 10
        num_aces -= 1
    return score
def display_board(player_cards, dealer_cards, show_dealer_card=False):
    print(f"{Fore.RED}-===== BLACKJACK =====-{Fore.WHITE}")
    print("Player's cards:")
    for card in player_cards:
        print(f"{card['rank']} of {card['suit']}")
    print(f"Total score: {calculate_score(player_cards)}\n")
    print("Dealer's cards:")
    if show_dealer_card:
        for card in dealer_cards:
            print(f"{card['rank']} of {card['suit']}")
        print(f"Total score: {calculate_score(dealer_cards)}\n")
    else:
        print(f"{dealer_cards[0]['rank']} of {dealer_cards[0]['suit']}")
        print("Hidden card\n")
def blackjack():
    player_cards = []
    dealer_cards = []
    deck = create_deck()
    player_cards.extend([deck.pop(), deck.pop()])
    dealer_cards.extend([deck.pop(), deck.pop()])
    game_over = False
    while not game_over:
        player_score = calculate_score(player_cards)
        dealer_score = calculate_score(dealer_cards)
        display_board(player_cards, dealer_cards)
        if player_score == 21:
            print("Blackjack! You win!")
            game_over = True
        elif dealer_score == 21:
            print("Dealer has a Blackjack. You lose.")
            game_over = True
        elif player_score > 21:
            print("You went over 21. You lose.")
            game_over = True
        elif dealer_score > 21:
            print("Dealer went over 21. You win!")
            game_over = True
        else:
            user_choice = input("Type 'y' to get another card, 'n' to pass: ").lower()
            if user_choice == 'y':
                player_cards.append(deck.pop())
            else:
                game_over = True
    while dealer_score < 17:
        dealer_cards.append(deck.pop())
        dealer_score = calculate_score(dealer_cards)
    display_board(player_cards, dealer_cards, show_dealer_card=True)
    if player_score > 21:
        print("You went over 21. You lose.")
    elif dealer_score > 21:
        print("Dealer went over 21. You win!")
    elif player_score == dealer_score:
        print("It's a draw.")
    elif player_score > dealer_score:
        print("You win!")
        print("You beat the dealer!")
        print("He lets you out and you escape!")
    print(f"{Fore.GREEN}You Win!!{Style.RESET_ALL}")
else:
print("You lose!")
print("The guard shoots you for trying to escape")
print("GAMEOVER!!! You lose")

if __name__ == "__main__":
                 blackjack()
else:
                 print("You grab the wrong rock and slip off, falling to your death.")
                 print("GAMEOVER! Please start again")
exit()

On line 173 It said invalid syntax Im not sure why
I have comments for school.

Hi @AndrewGlitzer!
That is an indent error. This is the corrected code.

import random
import time  # import time for time.sleep

from colorama import Fore, Style  # Used to color text

tele = False
# Determines the chance at the end to slip off or not
min = 1
max = 2
def randint(min, max):
    num = random.randint(1, 2)
    return num
NAMEE = input("Whats your name?")
print("\n *Flash back* ")
time.sleep(2)
print("/-------------------\\ ")
print("( Dear " + NAMEE + "            )")
print("(  We are sorry to  )")
print("(infrom you that you)")
print("(have been drafted  )")
print("(to war. We need you)")
print("( -USA Goverment    )")
print("\\-------------------/")
time.sleep(5)
print("\n *Pew* *Pew* ")
print("NOOOOOO")
print("\n *Goes into a deep coma* ")
time.sleep(5)
print(f"{Fore.GREEN}You wake up from your coma and realize you are stuck in a dungeon!{Style.RESET_ALL}")
print("[:::::=======:::::]")
print("[:::::( 0 0 ):::::]")
print("[:::::(  -  ):::::]")
print("[:::::( --- ):::::]")
print("[:::::=== ===:::::]")
print("[:::::::| |:::::::]")
print("[::::---| |---::::]")
print("[:::::::/ \\:::::::]")
print("   -(That's You)-   ")
print("You have to find a way out to survive.")
FOYOD = input("Do you want to 1. Yell for the guard 2. Flush yourself down the toilet or 3. disassemble the toilet: ")
if FOYOD == "1":
    print("You yell for the guard and he hears you.")
    print("Out of anger for waking him up from his nap he shoots you.")
    print("Gameover! Please start again")
elif FOYOD == "2":
    tele = True  # If FOYOD is 2, assigning True to tele
elif FOYOD == "3":
    print("You disassemble the toilet and find a key and a knife. Which one do you take?")
    KOK = input("1. Key 2. Knife: ")
    if KOK == "1":
        print("You pick up the key and realize it has a toxin in it. Later that day you die.")
        print("Gameover! Please start again")
    elif KOK == "2":
        print("You pick up the knife and you can do 2 things.")
        KYSOW = input("1. Stab yourself so you don't suffer or 2. stab the wall: ")
        if KYSOW == "1":
            print("You stab yourself and die. WHAT WERE YOU THINKING?!?!?!?!?!?!?!")
            print("Gameover! Please start again")
        elif KYSOW == "2":
            print(f"{Fore.RED}You stab the wall and it reveals a tunnel!{Fore.WHITE}")
            TON = input("Do you 1. Go into the tunnel or 2. stay in your cell: ")
            if TON == "2":
                print("You stay in your cell but the guard comes by and sees you with a knife. He then shoots you.")
                print("Gameover! Please start again")
            elif TON == "1" or tele:
                print("You flush yourself down the toilet and it reveals a tunnel")
                print("You go into the tunnel and it reveals two pathways.")
                LOO = input("Do you 1. Go left or 2. Go right: ")
                if LOO == "2":
                    print("You go right but another guard sees you and shoots you.")
                    print("Gameover! Please start again")
                elif LOO == "1":
                    print("You go left and you find a chest.")
                    print("You open the chest and find a cannon sword.")
                    PPP = input("Do you 1. Take the sword or 2. Leave the sword: ")
                    if PPP == "1":
                        print("You take the sword and you fight the guard.")
                        print("You fight the guard and you win!")
                    elif PPP == "2":
                        print("You leave the sword and you fight the guard.")
                        print("You lose badly. You get destroyed by his AK47.")
                        print("Gameover! Please start again")

if tele is True:
    print("You flush yourself down the toilet but more guards sees you")
FOR = input("Do you 1. Fight them or 2. Try to run away: ")
if FOR == "1":
    print("You attempt to fight back but you get shot.")
    print("GAMEOVER! Try again.")
elif FOR == "2":
    print("You run away and surprisingly don't get shot!")
    print("You see an opening in the dungeon and you begin to climb the wall.")
    JOS = input("Do you 1. grab the rock on the left or 2. the rock on the right: ")
    rand = randint(1, 2)
    if rand == 1 and JOS == "1" or rand == 2 and JOS == "2":
        time.sleep(2)
        print("...")
        print("You grab the rock and manage to slip out of the hole in the roof.")
        print("You run out of the area and escape!")
print("Before you leave another guard sees you.")
print("He tells you if you beat him in blackjack you can leave")
def create_deck():
    ranks = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']
    suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades']
    deck = [{'rank': rank, 'suit': suit} for rank in ranks for suit in suits]
    random.shuffle(deck)
    return deck
def calculate_score(cards):
    score = sum([11 if card['rank'] == 'A' else 10 if card['rank'] in ['K', 'Q', 'J'] else int(card['rank']) for card in cards])
    num_aces = sum([1 for card in cards if card['rank'] == 'A'])
    while score > 21 and num_aces:
        score -= 10
        num_aces -= 1
    return score
def display_board(player_cards, dealer_cards, show_dealer_card=False):
    print(f"{Fore.RED}-===== BLACKJACK =====-{Fore.WHITE}")
    print("Player's cards:")
    for card in player_cards:
        print(f"{card['rank']} of {card['suit']}")
    print(f"Total score: {calculate_score(player_cards)}\n")
    print("Dealer's cards:")
    if show_dealer_card:
        for card in dealer_cards:
            print(f"{card['rank']} of {card['suit']}")
        print(f"Total score: {calculate_score(dealer_cards)}\n")
    else:
        print(f"{dealer_cards[0]['rank']} of {dealer_cards[0]['suit']}")
        print("Hidden card\n")
def blackjack():
    player_cards = []
    dealer_cards = []
    deck = create_deck()
    player_cards.extend([deck.pop(), deck.pop()])
    dealer_cards.extend([deck.pop(), deck.pop()])
    game_over = False
    while not game_over:
        player_score = calculate_score(player_cards)
        dealer_score = calculate_score(dealer_cards)
        display_board(player_cards, dealer_cards)
        if player_score == 21:
            print("Blackjack! You win!")
            game_over = True
        elif dealer_score == 21:
            print("Dealer has a Blackjack. You lose.")
            game_over = True
        elif player_score > 21:
            print("You went over 21. You lose.")
            game_over = True
        elif dealer_score > 21:
            print("Dealer went over 21. You win!")
            game_over = True
        else:
            user_choice = input("Type 'y' to get another card, 'n' to pass: ").lower()
            if user_choice == 'y':
                player_cards.append(deck.pop())
            else:
                game_over = True
    while dealer_score < 17:
        dealer_cards.append(deck.pop())
        dealer_score = calculate_score(dealer_cards)
    display_board(player_cards, dealer_cards, show_dealer_card=True)
    if player_score > 21:
        print("You went over 21. You lose.")
    elif dealer_score > 21:
        print("Dealer went over 21. You win!")
    elif player_score == dealer_score:
        print("It's a draw.")
    elif player_score > dealer_score:
        print("You win!")
        print("You beat the dealer!")
        print("He lets you out and you escape!")
        print(f"{Fore.GREEN}You Win!!{Style.RESET_ALL}")
    else:
      print("You lose!")
      print("The guard shoots you for trying to escape")
      print("GAMEOVER!!! You lose")

if __name__ == "__main__":
                 blackjack()
else:
                 print("You grab the wrong rock and slip off, falling to your death.")
                 print("GAMEOVER! Please start again")
exit()

Hope this helps! Let me know if you need anything else.
If this helped, please mark this as the solution so others can access it easier.

2 Likes

Thank you so much I apperceate it A TON.

Im honestly so sorry but do you think you could fix this one more time? Please and thank you.

import random
import time # import time for time.sleep

from colorama import Fore, Style # Used to color text

tele = False
# Determines the chance at the end to slip off or not
min = 1
max = 2
def randint(min, max):
num = random.randint(1, 2)
return num
NAMEE = input("Whats your name?")
print("\n *Flash back* ")
time.sleep(2)
print("/-------------------\\ ")
print("( Dear " + NAMEE + " )")
print("( We are sorry to )")
print("(infrom you that you)")
print("(have been drafted )")
print("(to war. We need you)")
print("( -USA Goverment )")
print("\\-------------------/")
time.sleep(5)
print("\n *Pew* *Pew* ")
print("NOOOOOO")
print("\n *Goes into a deep coma* ")
time.sleep(5)
print(f"{Fore.GREEN}You wake up from your coma and realize you are stuck in a dungeon!{Style.RESET_ALL}")
print("[:::::=======:::::]")
print("[:::::( 0 0 ):::::]")
print("[:::::( - ):::::]")
print("[:::::( --- ):::::]")
print("[:::::=== ===:::::]")
print("[:::::::| |:::::::]")
print("[::::---| |---::::]")
print("[:::::::/ \\:::::::]")
print(" -(That's You)- ")
print("You have to find a way out to survive.")
FOYOD = input("Do you want to 1. Yell for the guard 2. Flush yourself down the toilet or 3. disassemble the toilet: ")
if FOYOD == "1":
print("You yell for the guard and he hears you.")
print("Out of anger for waking him up from his nap he shoots you.")
print("Gameover! Please start again")
elif FOYOD == "2":
tele = True # If FOYOD is 2, assigning True to tele
elif FOYOD == "3":
print("You disassemble the toilet and find a key and a knife. Which one do you take?")
KOK = input("1. Key 2. Knife: ")
if KOK == "1":
print("You pick up the key and realize it has a toxin in it. Later that day you die.")
print("Gameover! Please start again")
elif KOK == "2":
print("You pick up the knife and you can do 2 things.")
KYSOW = input("1. Stab yourself so you don't suffer or 2. stab the wall: ")
if KYSOW == "1":
print("You stab yourself and die. WHAT WERE YOU THINKING?!?!?!?!?!?!?!")
pprint(f"{Fore.RED}GAME OVER!!!! YOU LOSE{Style.RESET_ALL}")
elif KYSOW == "2":
print(f"{Fore.RED}You stab the wall and it reveals a tunnel!{Fore.WHITE}")
TON = input("Do you 1. Go into the tunnel or 2. stay in your cell: ")
if TON == "2":
print("You stay in your cell but the guard comes by and sees you with a knife. He then shoots you.")
print("Gameover! Please start again")
elif TON == "1" or tele:
print("You flush yourself down the toilet and it reveals a tunnel")
print("You go into the tunnel and it reveals two pathways.")
LOO = input("Do you 1. Go left or 2. Go right: ")
if LOO == "2":
print("You go right but another guard sees you and shoots you.")
print(f"{Fore.RED}GAME OVER!!!! YOU LOSE{Style.RESET_ALL}")
elif LOO == "1":
print("You go left and you find a chest.")
print("You open the chest and find a cannon sword.")
PPP = input("Do you 1. Take the sword or 2. Leave the sword: ")
if PPP == "1":
print("You take the sword and you fight the guard.")
print("You fight the guard and you win!")
elif PPP == "2":
print("You leave the sword and you fight the guard.")
print("You lose badly. You get destroyed by his AK47.")
print(f"{Fore.RED}GAME OVER!!!! YOU LOSE{Style.RESET_ALL}")

if tele is True:
print("You flush yourself down the toilet but more guards sees you")
FOR = input("Do you 1. Fight them or 2. Try to run away: ")
if FOR == "1":
print("You attempt to fight back but you get shot.")
print(f"{Fore.RED}GAME OVER!!!! YOU LOSE{Style.RESET_ALL}")
elif FOR == "2":
print("You run away and surprisingly don't get shot!")
print("You see an opening in the dungeon and you begin to climb the wall.")
JOS = input("Do you 1. grab the rock on the left or 2. the rock on the right: ")
rand = randint(1, 2)
if rand == 1 and JOS == "1" or rand == 2 and JOS == "2":
time.sleep(2)
print("...")
print("You grab the rock and manage to slip out of the hole in the roof.")
print("You run out of the area and escape!")
print("Before you leave another guard sees you.")
print("He tells you if you beat him in blackjack you can leave")
def create_deck():
ranks = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']
suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades']
deck = [{'rank': rank, 'suit': suit} for rank in ranks for suit in suits]
random.shuffle(deck)
return deck
def calculate_score(cards):
score = sum([11 if card['rank'] == 'A' else 10 if card['rank'] in ['K', 'Q', 'J'] else int(card['rank']) for card in cards])
num_aces = sum([1 for card in cards if card['rank'] == 'A'])
while score > 21 and num_aces:
score -= 10
num_aces -= 1
return score
def display_board(player_cards, dealer_cards, show_dealer_card=False):
print(f"{Fore.RED}-===== BLACKJACK =====-{Fore.WHITE}")
print("Player's cards:")
for card in player_cards:
print(f"{card['rank']} of {card['suit']}")
print(f"Total score: {calculate_score(player_cards)}\n")
print("Dealer's cards:")
if show_dealer_card:
for card in dealer_cards:
print(f"{card['rank']} of {card['suit']}")
print(f"Total score: {calculate_score(dealer_cards)}\n")
else:
print(f"{dealer_cards[0]['rank']} of {dealer_cards[0]['suit']}")
print("Hidden card\n")
def blackjack():
player_cards = []
dealer_cards = []
deck = create_deck()
player_cards.extend([deck.pop(), deck.pop()])
dealer_cards.extend([deck.pop(), deck.pop()])
game_over = False
while not game_over:
player_score = calculate_score(player_cards)
dealer_score = calculate_score(dealer_cards)
display_board(player_cards, dealer_cards)
if player_score == 21:
print("Blackjack! You win!")
game_over = True
elif dealer_score == 21:
print("Dealer has a Blackjack. You lose.")
print(f"{Fore.RED}GAME OVER!!!! YOU LOSE{Style.RESET_ALL}")
game_over = True
elif player_score > 21:
print("You went over 21. You lose.")
print(f"{Fore.RED}GAME OVER!!!! YOU LOSE{Style.RESET_ALL}")
game_over = True
elif dealer_score > 21:
print("Dealer went over 21. You win!")
game_over = True
else:
user_choice = input("Type 'y' to get another card, 'n' to pass: ").lower()
if user_choice == 'y':
player_cards.append(deck.pop())
else:
game_over = True
while dealer_score < 17:
dealer_cards.append(deck.pop())
dealer_score = calculate_score(dealer_cards)
display_board(player_cards, dealer_cards, show_dealer_card=True)
if player_score > 21:
print("You went over 21. You lose.")
elif dealer_score > 21:
print("Dealer went over 21. You win!")
elif player_score == dealer_score:
print("It's a draw.")
elif player_score > dealer_score:
print("You win!")
print("You beat the dealer!")
print("He lets you out and you escape!")
print(f"{Fore.GREEN}You Win!!{Style.RESET_ALL}")
else:
print("You lose!")
print("The guard shoots you for trying to escape")
print(f"{Fore.RED}GAME OVER!!!! YOU LOSE{Style.RESET_ALL}")

if __name__ == "__main__":
blackjack()
else:
print("You grab the wrong rock and slip off, falling to your death.")
print(f"{Fore.RED}GAME OVER!!!! YOU LOSE{Style.RESET_ALL}")
exit()

Sure, here’s the new code.

import random
import time # import time for time.sleep

from colorama import Fore, Style # Used to color text

tele = False
# Determines the chance at the end to slip off or not
min = 1
max = 2
def randint(min, max):
  num = random.randint(1, 2)
return num
NAMEE = input("Whats your name?")
print("\n *Flash back* ")
time.sleep(2)
print("/-------------------\\ ")
print("( Dear " + NAMEE + " )")
print("( We are sorry to )")
print("(infrom you that you)")
print("(have been drafted )")
print("(to war. We need you)")
print("( -USA Goverment )")
print("\\-------------------/")
time.sleep(5)
print("\n *Pew* *Pew* ")
print("NOOOOOO")
print("\n *Goes into a deep coma* ")
time.sleep(5)
print(f"{Fore.GREEN}You wake up from your coma and realize you are stuck in a dungeon!{Style.RESET_ALL}")
print("[:::::=======:::::]")
print("[:::::( 0 0 ):::::]")
print("[:::::( - ):::::]")
print("[:::::( --- ):::::]")
print("[:::::=== ===:::::]")
print("[:::::::| |:::::::]")
import random
import time  # import time for time.sleep
from colorama import Fore, Style  # Used to color text

tele = False
# Determines the chance at the end to slip off or not
min = 1
max = 2


def randint(min, max):
    num = random.randint(1, 2)
    return num


NAMEE = input("Whats your name?")
print("\n *Flash back* ")
time.sleep(2)
print("/-------------------\\ ")
print("( Dear " + NAMEE + " )")
print("( We are sorry to )")
print("(infrom you that you)")
print("(have been drafted )")
print("(to war. We need you)")
print("( -USA Goverment )")
print("\\-------------------/")
time.sleep(5)
print("\n *Pew* *Pew* ")
print("NOOOOOO")
print("\n *Goes into a deep coma* ")
time.sleep(5)
print(f"{Fore.GREEN}You wake up from your coma and realize you are stuck in a dungeon!{Style.RESET_ALL}")
print("[:::::=======:::::]")
print("[:::::( 0 0 ):::::]")
print("[:::::( - ):::::]")
print("[:::::( --- ):::::]")
print("[:::::=== ===:::::]")
print("[:::::::| |:::::::]")
print("[::::---| |---::::]")
print("[:::::::/ \\:::::::]")
print(" -(That's You)- ")
print("You have to find a way out to survive.")
FOYOD = input("Do you want to 1. Yell for the guard 2. Flush yourself down the toilet or 3. disassemble the toilet: ")

# ... rest of your code ...
print("[::::---| |---::::]")
print("[:::::::/ \\:::::::]")
print(" -(That's You)- ")
print("You have to find a way out to survive.")
FOYOD = input("Do you want to 1. Yell for the guard 2. Flush yourself down the toilet or 3. disassemble the toilet: ")
if FOYOD == "1":
  print("You yell for the guard and he hears you.")
  print("Out of anger for waking him up from his nap he shoots you.")
  print("Gameover! Please start again")
elif FOYOD == "2":
  tele = True # If FOYOD is 2, assigning True to tele
elif FOYOD == "3":
  print("You disassemble the toilet and find a key and a knife. Which one do you take?")
  KOK = input("1. Key 2. Knife: ")
  if KOK == "1":
    print("You pick up the key and realize it has a toxin in it. Later that day you die.")
    print("Gameover! Please start again")
  elif KOK == "2":
print("You pick up the knife and you can do 2 things.")
KYSOW = input("1. Stab yourself so you don't suffer or 2. stab the wall: ")
if KYSOW == "1":
print("You stab yourself and die. WHAT WERE YOU THINKING?!?!?!?!?!?!?!")
pprint(f"{Fore.RED}GAME OVER!!!! YOU LOSE{Style.RESET_ALL}")
elif KYSOW == "2":
print(f"{Fore.RED}You stab the wall and it reveals a tunnel!{Fore.WHITE}")
TON = input("Do you 1. Go into the tunnel or 2. stay in your cell: ")
if TON == "2":
print("You stay in your cell but the guard comes by and sees you with a knife. He then shoots you.")
print("Gameover! Please start again")
elif TON == "1" or tele:
print("You flush yourself down the toilet and it reveals a tunnel")
print("You go into the tunnel and it reveals two pathways.")
LOO = input("Do you 1. Go left or 2. Go right: ")
if LOO == "2":
print("You go right but another guard sees you and shoots you.")
print(f"{Fore.RED}GAME OVER!!!! YOU LOSE{Style.RESET_ALL}")
elif LOO == "1":
print("You go left and you find a chest.")
print("You open the chest and find a cannon sword.")
PPP = input("Do you 1. Take the sword or 2. Leave the sword: ")
if PPP == "1":
print("You take the sword and you fight the guard.")
print("You fight the guard and you win!")
elif PPP == "2":
print("You leave the sword and you fight the guard.")
print("You lose badly. You get destroyed by his AK47.")
print(f"{Fore.RED}GAME OVER!!!! YOU LOSE{Style.RESET_ALL}")

if tele is True:
print("You flush yourself down the toilet but more guards sees you")
FOR = input("Do you 1. Fight them or 2. Try to run away: ")
if FOR == "1":
print("You attempt to fight back but you get shot.")
print(f"{Fore.RED}GAME OVER!!!! YOU LOSE{Style.RESET_ALL}")
elif FOR == "2":
print("You run away and surprisingly don't get shot!")
print("You see an opening in the dungeon and you begin to climb the wall.")
JOS = input("Do you 1. grab the rock on the left or 2. the rock on the right: ")
rand = randint(1, 2)
if rand == 1 and JOS == "1" or rand == 2 and JOS == "2":
time.sleep(2)
print("...")
print("You grab the rock and manage to slip out of the hole in the roof.")
print("You run out of the area and escape!")
print("Before you leave another guard sees you.")
print("He tells you if you beat him in blackjack you can leave")
def create_deck():
ranks = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']
suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades']
deck = [{'rank': rank, 'suit': suit} for rank in ranks for suit in suits]
random.shuffle(deck)
return deck
def calculate_score(cards):
score = sum([11 if card['rank'] == 'A' else 10 if card['rank'] in ['K', 'Q', 'J'] else int(card['rank']) for card in cards])
num_aces = sum([1 for card in cards if card['rank'] == 'A'])
while score > 21 and num_aces:
score -= 10
num_aces -= 1
return score
def display_board(player_cards, dealer_cards, show_dealer_card=False):
print(f"{Fore.RED}-===== BLACKJACK =====-{Fore.WHITE}")
print("Player's cards:")
for card in player_cards:
print(f"{card['rank']} of {card['suit']}")
print(f"Total score: {calculate_score(player_cards)}\n")
print("Dealer's cards:")
if show_dealer_card:
for card in dealer_cards:
print(f"{card['rank']} of {card['suit']}")
print(f"Total score: {calculate_score(dealer_cards)}\n")
else:
print(f"{dealer_cards[0]['rank']} of {dealer_cards[0]['suit']}")
print("Hidden card\n")
def blackjack():
player_cards = []
dealer_cards = []
deck = create_deck()
player_cards.extend([deck.pop(), deck.pop()])
dealer_cards.extend([deck.pop(), deck.pop()])
game_over = False
while not game_over:
player_score = calculate_score(player_cards)
dealer_score = calculate_score(dealer_cards)
display_board(player_cards, dealer_cards)
if player_score == 21:
print("Blackjack! You win!")
game_over = True
elif dealer_score == 21:
print("Dealer has a Blackjack. You lose.")
print(f"{Fore.RED}GAME OVER!!!! YOU LOSE{Style.RESET_ALL}")
game_over = True
elif player_score > 21:
print("You went over 21. You lose.")
print(f"{Fore.RED}GAME OVER!!!! YOU LOSE{Style.RESET_ALL}")
game_over = True
elif dealer_score > 21:
print("Dealer went over 21. You win!")
game_over = True
else:
user_choice = input("Type 'y' to get another card, 'n' to pass: ").lower()
if user_choice == 'y':
player_cards.append(deck.pop())
else:
game_over = True
while dealer_score < 17:
dealer_cards.append(deck.pop())
dealer_score = calculate_score(dealer_cards)
display_board(player_cards, dealer_cards, show_dealer_card=True)
if player_score > 21:
print("You went over 21. You lose.")
elif dealer_score > 21:
print("Dealer went over 21. You win!")
elif player_score == dealer_score:
print("It's a draw.")
elif player_score > dealer_score:
print("You win!")
print("You beat the dealer!")
print("He lets you out and you escape!")
print(f"{Fore.GREEN}You Win!!{Style.RESET_ALL}")
else:
print("You lose!")
print("The guard shoots you for trying to escape")
print(f"{Fore.RED}GAME OVER!!!! YOU LOSE{Style.RESET_ALL}")

if __name__ == "__main__":
blackjack()
else:
print("You grab the wrong rock and slip off, falling to your death.")
print(f"{Fore.RED}GAME OVER!!!! YOU LOSE{Style.RESET_ALL}")
exit()

Theres still invalid syntax around 99-100 and indentation errors. Is there any way I can get ai to fix it?

Yes, you can ask Replit Ghostwriter to fix your code.

I dont have pro though

Replit AI (GhostWriter) is now free for everyone. Go to Tools > AI.
Hope this helps!

??? this is wrong, it would still give an indent error

1 Like

I think it’d cause a different error, right?

oh, cause the return outside of a function. :woman_shrugging:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.