I think some things may be helpful.
It looks like you are on a Windows system, so you need to use double backslashes "\\" to separate folders.
Secondly, if you are trying to navigate to a folder in the current folder, you should use one point, not two, for example. os.chdir ('. \\ folder')
Finally, if the folder you are trying to access is not a direct subfolder of the current working directory (or else in your path), you need to include the full path to access it. Since you said this on your desktop, you probably want something similar to this:
import os os.chdir('C:\\Users\\username\\Desktop\\headfirstpython')
Here you can also change directories in the Chapter3 subdirectory with the following
os.chdir('chapter3')
Which is equivalent in this case with
os.chdir('.\\chapter3')
or, if you want to be verbose:
os.chdir('C:\\Users\\username\\Desktop\\headfirstpython\\chapter3')
Hope this helps?
Brandon
source share