Can someone help me debug my code?

also does anyone know why my code doesnt work?
im new to python!

If you change

elif(Assassins == "0"):print("wow")


if Assassins == "0":

It should work

To me it looks like some sort of indent or spaces problem (be warned I’m terrible at python bugs)

Is right now:

elif(Assassins == “0”):print(“wow”)

My guess at what it should be:

elif (Assassins == “0”):

And @JohnnySuriano I think stuff like: if example == “example”:print(“hi”) should work.

That probably works but using indents is more clear, especially when your doing larger bits of code, and because this looks like an story game it will probably have a lot of code after it but I guess it’s more personal preference

No according to my test it doesn’t work rn but I was having problems with the .nix file so I’ll have to find out what the problem is later.

@Galaxyzeke42 I forked your repl and fixed all the indents and errors I could find, lmk if this doesn’t run they way its meant to

Fixed Code:

# Print a Welcome message
print("Welcome to Dungeons And Dynasty")
print("""In this mysterious land, you are an adventurer traveling lands
for the sacred Sword of Algrah!""")
print("What is your name?")

# Prompt User for a name
Username = input()

print("Hello " + Username + "!")
print("You wake up inside a tent with your group")
print("You and your group of travelers enter a stand")
print("You walk up to a stand selling riches and valuables")
print("Do you want to STEAL the valuables or walk away?")
print("Type 1 to steal the Valuables or type 2 to walk away")

# Prompt user for a choice
ActChoice = input("> ")

if ActChoice == "1":
    print(Username + " decides to steal the valuables!")
    print("The owner of the valuables gets angry and starts chasing you!")
    print("""You and your group start running at high speed but run into 
    two different paths! What path do you pick?""")
    print("Pick path LEFT or RIGHT")
    print("Type 3 for LEFT or 4 for RIGHT")

    # Prompt user for a path choice
    PathChoice = input("> ")

    if PathChoice == "3":
        print("You run into a Dead End causing the Owner and the Guards to catch you!")
        print("You and your group are now locked in prison for many years")
    elif PathChoice == "4":
        print("You and your group find a large forest and run into it, causing the Owner and guards to lose track of you!")
        print("Invalid choice. Next time please enter 3 or 4.")
elif ActChoice == "2":
    print("You decide to walk away from the stand, but a group of assassins find you and attempt to kill you!")
    print("You and your group can use your old weapons to kill them or hide from the enemies, possibly saving the weapons from breaking.")
    print("Type 9 to attack the assassins or type 0 to hide from the assassins!")

    # Prompt user for a choice regarding the assassins
    Assassins = input("> ")

    if Assassins == "9":
        print("You decide to attack the assassins.")
        print("You and your group start pulling out withered katanas.")
        print("You ended up killing the assassins and you find a wanted poster of the assassins!")
        print("You turned in the assassins gaining money from their bounty!")
        print(Username + " thinks about betraying his crew and taking the money with you!")
    elif Assassins == "0":
        print("Invalid choice. Next time please enter 9 or 0.")
    print("Invalid choice. Next time please enter 1 or 2.")

Also for future reference is their a Code Help post about this?

1 Like

Usually if you want help with your code you would post your question on a new topic in the specific code help for the language you are using.

thank you for the help!

1 Like

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