Create new folders using python
python
Solution
import os, sys
a= [4,3,2,1]
print len(a)
for idx in range (len(a)):
newpath = ((r'E:\test\tool\folder_%s') % (idx))
if not os.path.exists(newpath): os.makedirs(newpath)
Try that, if it helps, accept the answer, if not leave a comment and I'll delete it.
Problem
I am trying to create folders using the following code. Something is not correct and leads to error: "TypeError: 'str' object is not callable" ``` import os, sys a= [4,3,2,1] print len(a) for idx in range (len(a)): newpath = r'E:\test\tool\folder_%s'(idx) if not os.path.exists(newpath): os.makedirs(newpath) ``` Using os.makedirs I can create folders. However, I am not able to suffix those folders in a loop. Any ideas can be helpful. Thanks.