Convert a datetime list into date in Python
<p>I have a datetime list and would like to convert it into a date using the following code:</p>
<pre><code>dates = (datetime.strptime(ts, '%Y-%m-%d %H:%M:%S') for ts in timestamps)
date_strings = [datetime.strftime(d, '%m-%d-%Y') for d in dates]
</code></pre>
<p>The datetime list looks like the following:</p>
<blockquote>
<p>[datetime.datetime(2016, 11, 21, 0, 0), datetime.datetime(2016, 11,
22, 0, 0), datetime.datetime(2016, 11, 23, 0, 0)]</p>
</blockquote>
<p>I receive the following error message:</p>
<blockquote>
<p>TypeError: strptime() argument 1 must be str, not datetime.datetime</p>
</blockquote>