title: How to write JSON to a file with a generic name?
body: <p>I'm writing a script that works with certain vocabulary. As a part of it, I want to store the incoming json data of a word in a file. The following code works only for one word at a time. But it will replace the <code>data.json</code> file every time with the json information of the new word. </p>
  
  <pre><code>with open('data.json', 'w') as outfile:
      json.dump(data, outfile)
  </code></pre>
  
  <p>What I'm trying to achieve is: I would like to store the json of each file separately.
  For eg: if the word is "internet", then I want the file to export <code>internet.json</code> and if the word is "persistence," then i want the json to store <code>persistence.json</code></p>
  
  <p>I tried the below, but it throws a syntax error:.</p>
  
  <pre><code>with open(word||'.json', 'w') as outfile:
      json.dump(data, outfile)
  </code></pre>
  
  <p>I'm new to Python (using Python3) and I'm working on a pet-project. So, it would be a great support if you can help me in achieving this. Thanks in advance.</p>