Portable Path Building

Easy ⏱ 8 min 79% acceptance ★★★★★ 4.9
Hardcoding '/' breaks on Windows. Write report_path(base, year, month, name) that joins the pieces into base/<year>/<month>/<name>.csv using os.path.join (month zero-padded to 2 digits), letting the OS pick the separator.

Examples

Example 1
Input
report_path('data', 2026, 7, 'sales')
Output
'data/2026/07/sales.csv' (or backslashes on Windows)
Explanation

join inserts the platform separator.

Constraints

  • Use os.path.join, never manual separators.
  • Zero-pad the month.

Topics

Modules & Packagesos.path

Companies

MicrosoftIBMAccenture

Hints

Hint 1

str(year) and f"{month:02d}" prepare the parts.

Hint 2

Append .csv to the name before joining.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.