title: Decimal to Roman conversion program giving wrong answer in Python
body: <p>I am writing a program to convert Decimal number to roman, but it is not printing correct answer for some numbers.</p>
  <p>Here is my python code.</p>
  <pre><code>num = 600
  
  d = {
      1: &quot;I&quot;,
      4: &quot;IV&quot;,
      5: &quot;V&quot;,
      9: &quot;IX&quot;,
      10: &quot;X&quot;,
      40: &quot;XL&quot;,
      50: &quot;L&quot;,
      90: &quot;XC&quot;,
      100: &quot;C&quot;,
      400: &quot;CD&quot;,
      500: &quot;D&quot;,
      900: &quot;CM&quot;,
      1000: &quot;M&quot;,
  }
  
  t = 0
  ans = &quot;&quot;
  while num&gt;0:
      for key in d.keys():
          if key &lt; num:
              t = key
      num -= t
      ans = ans + d[t]
  
  print(ans)
  </code></pre>
  <p>It prints <code>DXCIXIX</code> but the answer should be <code>DC</code></p>