Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialViola Wong
4,117 Pointscan somebody help me with this?
I need to get to the directory above the one I'm currently in. Finish this code snippet for me:
os.path.join(os.getcwd(), " ")
1 Answer
Jeff Muday
Treehouse Moderator 28,720 PointsTry this...
import os
# get current directory, and print
path = os.getcwd()
print(f"current dir = {path}")
# get the parent directory, and then print
parent = os.path.abspath(os.path.join(path, os.pardir))
print(f"parent dir = {parent}")
If you want the answer to the quiz, remember the ".." refers to the parent of the current directory!
Viola Wong
4,117 PointsViola Wong
4,117 Pointsthanks!