$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · medium · #187

Which fix removes the bug?

import os
path = os.path.join('/data', '/logs')
print(path)
  1. Drop the second leading slash
  2. Use string concatenation
  3. Call os.path.abspath first
  4. Swap the two arguments
An absolute component discards everything before it, so the result is just '/logs'.
Play Problem Solving ▸