mkdir takes as an argument a string. You are passing it a generator expression that will generate successive values '1', '2', ... '10' when you iterate it. You need to use a loop to make individual calls passing a single string argument:
import os
for i in range(1, 11):
os.mkdir(str(i))
By the way, the expression list(range(1, 11)) will create a list from a range object. But if you are going to be using the result in a for loop as in the above code, it is wasteful to create the list; just use the range object directly.
mkdir
takes as an argument a string. You are passing it a generator expression that will generate successive values '1', '2', ... '10' when you iterate it. You need to use a loop to make individual calls passing a single string argument:By the way, the expression
list(range(1, 11))
will create alist
from arange
object. But if you are going to be using the result in afor
loop as in the above code, it is wasteful to create the list; just use therange
object directly.