title: format strings and named arguments in Python
body: <p><strong>Case 1:</strong></p>
  <pre><code>&quot;{arg1} {arg2}&quot;.format(10, 20)
  </code></pre>
  <p>It will give <code>KeyError: 'arg1'</code> because I didn't pass the named arguments.</p>
  <p><strong>Case 2:</strong></p>
  <pre><code>&quot;{arg1} {arg2}&quot;.format(arg1=10, arg2=20)
  </code></pre>
  <p>Now it will work properly because I passed the named arguments.
  And it prints <code>'10 20'</code></p>
  <p><strong>Case 3:</strong></p>
  <p>And, If I pass wrong name it will show <code>KeyError: 'arg1'</code></p>
  <pre><code>&quot;{arg1} {arg2}&quot;.format(wrong=10, arg2=20)
  </code></pre>
  <p>But,</p>
  <p><strong>Case 4:</strong></p>
  <p>If I pass the named arguments in <strong>wrong order</strong></p>
  <pre><code>&quot;{arg1} {arg2}&quot;.format(arg2=10, arg1=20)
  </code></pre>
  <p><em>It works...</em></p>
  <p>and it prints <code>'20 10'</code></p>
  <p>My question is why does it work and what's the use of <strong>named arguments</strong> in this case.</p>