-2

I'm trying to update path in path 3 to 2 so it prints path 2 but it won't work. Is there anyway I can fix this?

def direction():
    time.sleep(0.3)
    print("=====================================================================")
    time.sleep(0.3)
    print("You look around")
    time.sleep(0.3)
    print("1 or 2?")
while path == 2:
    print("Other path")
while path == 3: 
    print("=====================================================================")
    time.sleep(0.3)
    print("You look down to see a bunch of tools scattered around on the floor.")
    press_enter()
    time.sleep(0.3)
    print("1. Look through tools")
    time.sleep(0.3)
    print("2. Go back")
    tools = int(input("Which way should you look? (1/2) - "))
    if tools == 1:
        
        if screwdriver == 1:
            time.sleep(0.3)
            print("After searching through the tools you find a decent screwdriver.")
            screwdriver = 2
            direction()
            path = int(input("Which way should you look? (1/2/3/4) - "))
        elif screwdriver == 2 or 3:
            time.sleep(0.3)
            print("There are no other tools in usable conditions.")
            direction()
            path = int(input("Which way should you look? (1/2/3/4) - "))
    if tools == 2:
        direction()
        path = int(input("Which way should you look? (1/2/3/4) - "))
khelwood
  • 55,782
  • 14
  • 81
  • 108
tater tot
  • 1
  • 1

2 Answers2

1

I am not sure I understand what you actually want to do. But there is one obvious problem and that is infinite while loop. You have to update the path inside the loop.

-1

I do believe this is not the entire code...... You can send the python file directly to me via kelvinlikel@gmail.com

Then for a while loop, there are three things u must keep in mind.

  1. Initialize the Iterator
  2. Specify a condition
  3. Increment the iterator.

From your code here, I can't find the iterator, it wasn't incremental as well.

Moreover one while loop could have sorted the path == 2, path == 3 I can see on ur code.