title: Need to convert 3 letter month code to two letter month code python
body: <p>I am trying to get a date formatted, i.e., from <code>Jan</code> to <code>JA</code>, <code>Feb</code> to <code>FE</code>. I have a dictionary built to do this, however my code only works randomly, e.g., sometimes every 4 times, sometimes every 24 times. I am new to Python, and I can't make sense of this. The output from the below code is <code>16Jun28</code> most of the time, but correctly <code>16JN28</code> sometimes.     </p>
  
  <pre><code>import datetime
  month_code = {'Jan': 'JA', 
        'Feb': 'FE', 
        'Mar': 'MR', 
        'Apr': 'AL', 
        'May': 'MA', 
        'Jun': 'JN', 
        'Jul': 'JL', 
        'Aug': 'AU', 
        'Sep': 'SE', 
        'Oct': 'OC', 
        'Nov': 'NO', 
        'Dec': 'DE'}
  
  today = datetime.datetime.now()
  DD = datetime.timedelta(days=90)    
  use_by = today + DD
  use_by_str = use_by.strftime("%y-%b-%d")
  
  def label_function():
      month = use_by.strftime("%b")
      year = use_by.strftime("%y")
      day = use_by.strftime("%d")
      return year + month + day
  
  line = label_function()
  
  for k, v in month_code.items():
      Result = line.replace(k, v)
  print(Result)
  </code></pre>