title: Changing directories in python using the os library
body: <p>I have been trying to make a python code to move throughout directories, but it keeps throwing error after error. Here is the code: </p>
  
  <pre><code>import os
  def ddir(x):          # ↓ way to access a user input directory
      os.chdir(os.getcwd() )
      print("Changed to the", os.getcwd(), "directory.")
  while True:
      try:
          _h = input('')
          if (_h == 'dir'):
             ddir(_h)
      #except is further down in the code
  </code></pre>
  
  <p>I have tried multiple different ways including the <code>shutil</code> library and they have not worked.</p>