title: How to to check if a folder doesn't exist to create a file inside of it?
body: <p>I am trying to check if folder exist if not the system create it and a JSON file will be written inside this folder.</p>
  
  <p>The problem is that the system create an empty folder and displays this error:</p>
  
  <pre class="lang-none prettyprint-override"><code>None
  
   the selected file is not readble because :  [WinError 183] Cannot
   create a file when that file already exists: './search_result'
   'NoneType' object is not iterable
  </code></pre>
  
  <p><code>None</code> is the result of: <code>print(searchResultFoder)</code>.</p>
  
  <p>The code is:</p>
  
  <pre><code>if not(os.path.exists("./search_result")):                                      
                      today = time.strftime("%Y%m%d__%H-%M")
                      jsonFileName = "{}_searchResult.json".format(today)
                      fpJ = os.path.join(os.mkdir("./search_result"),jsonFileName)
                      print(fpJ)
  with open(fpJ,"a") as jsf:
                      jsf.write(jsondata)
                      print("finish writing")
  </code></pre>