title: Need some help in formatting strings in Python
body: <p>I am trying to get an output similar to this.</p>
  <pre><code>{
    &quot;Continent&quot;: &quot;Asia&quot;,
    &quot;Country&quot;: &quot;Japan&quot; 
  } 
  </code></pre>
  <p>The code below is throwing an error.</p>
  <pre><code>    var = &quot;Japan&quot;
  message_body_3 = '{\n  \&quot;Continent\&quot;: \&quot;Asia\&quot;,\n  \&quot;Country\&quot;: \&quot;{0}\&quot; \n} '.format(var)
  </code></pre>
  <p>Error:</p>
  <pre><code>    message_body_3 = '{\n  \&quot;Continent\&quot;: \&quot;Asia\&quot;,\n  \&quot;Country\&quot;: \&quot; {0} \&quot; \n} '.format(var)
  KeyError: '\n  &quot;Continent&quot;'
  </code></pre>
  <p>I want the {0} to be replaced with my variable.</p>
  <p>What's the best way to achieve the result. I need to have backslashes and quotes in my string. Is there any way to do this in python ?</p>