Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Alexander Davison
65,456 PointsProblem with get_root(). Help would be appreciated.
It says:
Bummer! ValueError: 'examples' does not start with '/workdir'
I don't understand what's wrong... What is "examples"?
Help appreciated! ~Alex
import pathlib
import os
def get_root():
root = pathlib.PurePath(
input("What's the full path where you'd like the project? ")
)
cwd = pathlib.PurePath(os.getcwd())
if root.relative_to(cwd):
return cwd.joinpath(root)
if root.is_absolute():
return root
return get_root()
Tagging Chris Freeman + Steven Parker for help

Alexander Davison
65,456 PointsThanks anyway :)
1 Answer

Chris Freeman
Treehouse Moderator 68,167 PointsYour two return values are correct. It is the flow logic that fails the challenge.
The PurePath.relative_to() seems to only work when the comparison is between paths where one is contained in the other.
A simple reorganization of checking if root.is_absolute()
works followed by a simple else
with your other return value cwd.joinpath(root)
On coding style: I would also suggest that since it is not known if the input path is actually an absolution path, using the variable name root
seems confusing. I would suggest using "path" or "project_path". This makes joining cwd with project_path clearer.
Post back if you need more help. Good luck!

Alexander Davison
65,456 PointsThanks :)
Steven Parker
221,330 PointsSteven Parker
221,330 Points