Python – function to write multiple files with loop

  python, python-3.x

I’m trying to write a function that would use a loop to write multiple files, but it’s not succeeding. Here are the code, and the result. The directory does exist; I was able to write, read, and append single files to it with no problem. This was done in the ordinary Python 3.9 interactive command line window on Windows 10.

Any help much appreciated.

def writepages(i):

for j in range(i):

name = f"0{j}0page.html"

    file = open(f'C:UserscumminjmDocuments{name}', 'r+')


Traceback (most recent call last):
File "", line 1, in
File "", line 4, in writepages
FileNotFoundError: [Errno 2] No such file or directory: ‘C:UserscumminjmDocuments{$content}0page.html’

Source: Python Questions