title: How can I return to the start of a loop so I can request again for input of the user after wrong input?
body: <p>I want the user to enter a path to a directory as input. The program should check if this path really exists. If the path exists it should execute the rest of the code.  </p>
  
  <p>If the path does not exist it should print that it is a non existing path and I want it to request the user again to input a path, until the user enters a path that exists. </p>
  
  <p>I have tried it with a while loop, with try and except and with if and else statements but I can't get it error free. </p>
  
  <p>This is my current code:</p>
  
  <pre><code>i = 0
  
  while i&lt;1:
  
      input = input("Please enter path to directory: ")
      if os.path.exists(input) == False:
          print("This path does not exist")
  
  
      elif os.path.exists(input) == True:
          os.chdir(input)
          execute_code(input)
          i +=1
  </code></pre>
  
  <p>If the user enters an existing path everything works fine, but if the path does not exist it prints that the path does not exist but it will show an error and will not request again for input.</p>
  
  <p>What do I need to change so the program will ask the user again for input?</p>