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 trial

Python Python for File Systems Navigation Absolutely

Now I need you to write a function named absolute that takes two arguments, a path string and a root string. If the path

Now I need you to write a function named absolute that takes two arguments, a path string and a root string. If the path is not already absolute, return the path with the root prepended to it.

absolute.py
import os
os.path.isabs("home/absolute")

1 Answer

you can use the .isabs() function to check if the path is absolute, if it returns True you can just return the path the way it is, and if it isn't you could do something like return root + path