Skip to content

Instantly share code, notes, and snippets.

@ohforest
Forked from RabeyaMuna/Q4.py
Created July 1, 2024 10:01
Show Gist options
  • Save ohforest/0b04ab1112f86fc3ebe888a628a3884d to your computer and use it in GitHub Desktop.
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.
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