I want to be able to create 5 sub-directories of a folder using a loop in python. They should all have the name subdir_n where n is a number from 1 through 5. I tried this using a for loop, but I can't seem to get the naming right. Here is what I am using.
subdir_n
n
for
import os def createSubDirectories(): for i in range(1,6): os.mkdir('/home/student/lab3/subdir_{i}') createSubDirectories()
The formatting you seem to want to use is f-string, and you need to prefix the string by an f
f-string
f
f'/home/student/lab3/subdir_{i}'
1.4m articles
1.4m replys
5 comments
57.0k users