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 trialLiv B
Courses Plus Student 51 Pointsabsolute.py task 2
I don't know what I'm doing wrong
def absolute(path, root):
path = "projects\\python_basics\\"
root = "C:\\"
if not os.path.isabs(path):
join_path = root + path
return join_path
else:
return path
3 Answers
Andreas cormack
Python Web Development Techdegree Graduate 33,011 PointsHi Liv
try this
def absolute(path, root):
path = "\\projects\\python_basics\\"
root = "C:"
if not os.path.isabs(path):
join_path = root + path
return join_path
else:
return path
According to the docs, os.path.isabs chops of the drive letter, so your path should start with 2 backslashes on Windows and a forward slash on unix. See how this works? I don't work on windows so cannot test it.
Liv B
Courses Plus Student 51 PointsI don't know what else to try, that still doesn't work
Liv B
Courses Plus Student 51 PointsIt worked!!! thank you. The challenge did not want path and root defined. I commented them out and it worked just fine