-
-
Save ohforest/0b04ab1112f86fc3ebe888a628a3884d 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. Remember that '..' is a relative path alias that means "go up to the parent directory". Fill in the gaps to complete this function.
This file contains 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 | |
relative_parent = os.path.join(os.getcwd(), os.pardir) | |
# Return the absolute path of the parent directory | |
return os.path.abspath(relative_parent) | |
print(parent_directory()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment