I can not understand what is wrong in this code, os.makedirs creates 1 folder, and the 2nd refuses for reasons I do not understand, please tell me.

import os class Newclass : intstring = 1; def mainfunc(self, a, b): print(a) print(b) if os.path.exists(a) and os.path.exists(b): print ("OK...") else: print ("Creating Dirs...") if os.makedirs(a) and os.makedirs(b): print ("MakeDirs - OK") else: print ("MakeDirs - Error") A = Newclass() A.mainfunc("/home/pc/1", "/home/pc/2") 

    1 answer 1

    os.makedirs returns None if successful (throws an exception if os.makedirs(a) and os.makedirs(b): ), so the second call in if os.makedirs(a) and os.makedirs(b): no longer occurs and the directory /home/pc/2 not created.