Search code examples
pythonfor-loopgoogle-colaboratory

How to make 80 folders using Python


I want to make 79 folder in my drive and want folder name is a number 1 to 79. this is my code. I used Google colab

import os
for i in range(1,80):
  folder = "/content/drive/My Drive/project/Dataset"
  os.makedirs(folder[i])

Please Help. My code can be change if you have any thought.


Solution

  • Use:

    import os
    
    folder = "/content/drive/My Drive/project/Dataset"
    for i in range(1,80):
        os.mkdir(os.path.join(folder,str(i)))