Hello, I'm totally new to programming and wanted to make a text-based game based on what I know, but I've met a problem I don't know how to fix. Also this code is not finished, I'm just trying to get it to work first.
Basically, I want the loop to re-start. I tried many different ways, but none worked.
Again, I'm totally new to programming and am sorry if everything is completely wrong. Here's the code:

start = raw_input("Enter Start to start the game:")

if start == "Start" or "start":
    print "Welcome to the game!"
    print "Your adventure starts in your home."
    houseDecision = raw_input ("After you left the house the path continued two different ways. Which path would you like to take? (Left, Right)")
    while houseDecision == "Right":
        fightorRun = raw_input("You started walking to the right and a Ghoul jumped at you from the tall grass. What would you like to do? (Run back, Fight)")
        if fightorRun == "Run back":
            houseDecision = raw_input("You ran back where the two ways parted. Which way would you like to choose now? (Left, Right)")
    while houseDecision == "Left":
        pickup = raw_input("When you took the left path you found an Iron Sword hidden in the grass. Take it? (Yes, No)")
        if pickup == "Yes":
            inventory.append("Iron Sword")
            print "You took the Iron Sword into your inventory."
        goback = raw_input("Do you want to continue going or go back? (Continue, Back)")
        if goback == "Back":
            houseDecision = raw_input("Where do you want to go? (Left, Right)")

I want to go from line 18 to line 6.

Edited 2 Months Ago by Artur_5

Try adding a loop to encompass or enclose what you want to loop on.

In psuedocode.
loop
what you want to loop on
until exitcondition.

I kinda fixed it by making a for loop.
I'm not really sure what I did here, but for now it works. An explanation or a better way of doing this would be appreciated.

inventory = [
    "Health Pack",
    "Wooden Sword",
]

start = raw_input("Enter Start to start:")
if start == "Start":
    for loop in start:
        houseDecision = raw_input ("After you left the house the path continued two different ways. Which path would you like to take? (Left, Right)")
        while houseDecision == "Right":
            fightorRun = raw_input("You started walking to the right and a Ghoul jumped at you from the tall grass. What would you like to do? (Run back, Fight)")
            if fightorRun == "Run back":
                houseDecision = raw_input("You ran back where the two ways parted. Which way would you like to choose now? (Left, Right)")
        while houseDecision == "Left":
            pickup = raw_input("When you took the left path you found an Iron Sword hidden in the grass. Take it? (Yes, No)")
            if pickup == "Yes":
                inventory.append("Iron Sword")
                print "You took the Iron Sword into your inventory."
            goback = raw_input("Do you want to continue going or go back? (Continue, Back)")
            if goback == "Back":
                houseDecision = raw_input("Are you sure? (Yes, No)")

You could replace line 7 with

while start == 'Start':

and remove the for loop in start, which is not good: loop takes the values 'S', 't', 'a', 'r', 't', then the loop exits. This is probably not what you want.

Okay, I did as you said, but now each time the loop ends it starts over. How do I exit the loop?

Edited 2 Months Ago by Artur_5

This question has already been answered. Start a new discussion instead.