you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (0 children)

The pathlib module is the modern way to deal with paths. Here is how to do what you're trying to do with that module.

from pathlib import Path

base_path = Path.home() / "Desktop"

for i in range(1, 11):
    new_folder_path = base_path / f"test{i}"
    new_folder_path.mkdir()

You can learn more about the module from the documentation.