In Python3, os.makedirs has a default parameter exist_ok=False.
If you set it to True, then os.makedirs will not throw any exception if the leaf exists.
(While os.mkdir doesn't have this parameter.)
Just like this:
os.makedirs('dirA', exist_ok=True)
P.S.
You can type ? before the name of a method in IPython shell to take a quick look at the documentation.
e.g.:
makedirs : Recursive directory creation function. Like mkdir(), but makes all intermediate-level directories needed to contain the leaf directory. Raises an error exception if the leaf directory already exists or cannot be created.