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.

Python Python for File Systems Project Starter Solid Paths

``import pathlib def get_root(): root = pathlib.PurePath( input("What's the full path where you'd ``

What is wrong with this code for the challenge builder.py?

I got Bummer! Couldn't import get_root.

builder.py
import pathlib


def get_root():
    root = pathlib.PurePath(
        input("What's the full path where you'd like the project? ")
    )
    if not root.is_absolute():
        return get_root()
    return root


def main():
    project_root = get_root()
    project_name = None
    while not project_name:
        project_name = input("What's the full name for the project?").strip()

    print("Creating {} in {}".format(project_name, project_root))    


if _name_ == '_main_':
    main()

1 Answer

Steven Parker
Steven Parker
216,135 Points

It doesn't look like you've changed "get_root" yet. But perhaps more significant, it looks like there's a lot of added code outside of the function that isn't related to the challenge.

For this challenge, you'll make a small modification to the provided "get_root" function. You won't add any code outside of the function.

I am a coding newbie, how do I modify the get_root? Does it have to be changed to a string? If so, how do you change it to a string?

Steven Parker
Steven Parker
216,135 Points

The instructions say "... if the path is relative, change it into an absolute path.". You won't need to convert anything into a string, you can do this using methods from the "pathlib" library. You might need to look over the library documentation a bit to get familiar with it.

Also, depending on how much of a "newbie" you are, you might want to take some other courses before this one, even though it's classed "beginner" level. I would recommend that beginners start with the Learn Python track.