title: Python Datetime Strptime Error: '-' is a bad directive in format '%-m-%-d-%y %-H:%M:%S'
body: <p>I know that there have been similar questions asked, but they seemed to have to do with the way datetime deals (or doesn't deal) with timezones.</p>
  
  <p>The setup is a little complicated, and probably not relevant to the problem, but I thought it was important to include the code as is, so a little background:</p>
  
  <p>I've got a dictionary of arrays. Each of these arrays represents an "attempt" by the same person, but taking place at different times. Ultimately I'm going to be looking for the earliest of these dates. This may be a bit of a roundabout solution, but I'm converting all of the dates to datetime objects, finding the earliest and then just using that index to pull out the first attempt:</p>
  
  <p>Here's what the code looks like to setup that array of attempt datetimes:</p>
  
  <pre><code>for key in duplicates_set.keys():
      attempt_dates = [datetime.strptime(attempt['Attempt Date'], "%-m-%-d-%y %-H:%M:%S") for attempt in duplicates_set[key]]
  </code></pre>
  
  <p>Here's the format of what one of the original date strings looks like:</p>
  
  <p><code>12-5-2016  3:27:58 PM</code></p>
  
  <p>What I'm getting back is:</p>
  
  <pre><code>ValueError: '-' is a bad directive in format '%-m-%d-%y %-H:%M:%S'
  </code></pre>
  
  <p>I assume that's referring to the dashes placed before the 'm', 'd' and 'H' because they're non-zero-padded decimals. Why is it telling me that?</p>