Created
October 26, 2020 11:57
-
-
Save pandorica-opens/c05fb5a0527e193e6293274f9022a6f5 to your computer and use it in GitHub Desktop.
The parent_directory function returns the name of the directory that's located just above the current working directory.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| def parent_directory(): | |
| # Create a relative path to the parent | |
| # of the current working directory | |
| os.chdir('..') | |
| relative_parent = os.path.abspath(os.getcwd()) | |
| # Return the absolute path of the parent directory | |
| return relative_parent | |
| print(parent_directory()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment