title: How to "cd" between directories using a python script
body: <p>I'm writing a test script that is supposed to cd from the current directory into a new one if that path is confirmed to exist and be a directory</p>
  
  <pre><code>serial_number = input("Enter serial number: ")
  directory = "/etc/bin/foo"
  if os.path.exists(directory) and os.path.isdir(directory):
     #cd into directory?
     subprocess.call(['cd ..' + directory])
  </code></pre>
  
  <p>My dilemma is that I don't know how to properly pass a variable into a subprocess command, or whether or not I should use call or Popen. When I try the above code, it comes back with an error saying that <code>No such file or directory "cd ../etc/bin/"</code>. I need is to travel back one directory from the current directory so then I can enter <code>/etc</code> and read some files in there. Any advice?</p>