title: How do I divide a date range into months in Python?
body: <p>I have the following date range:</p>
  
  <pre><code>begin: 2018-02-15
  end: 2018-04-23
  </code></pre>
  
  <p>I want to achieve the following:</p>
  
  <pre><code>["2018-02-15 - 2018-02-28", "2018-03-01 - 2018-03-31", "2018-04-01 - 2018-04-23"]
  </code></pre>
  
  <p>Essentially, I want to divide a given date range into months. I can't think of a way to accomplish this in Python.</p>
  
  <p>I have considered the solution <a href="https://stackoverflow.com/questions/29721228/given-a-date-range-how-can-we-break-it-up-into-n-contiguous-sub-intervals">here</a>, however, this splits the date range based on a specified interval. I want to be able to split a date range dynamically. </p>
  
  <p>Hence, given a date range from 15 February 2018 to 23 April 2018, I want to be able to get the individual months in the range, like so:</p>
  
  <ul>
  <li>15 February 2018 to 28 February 2018</li>
  <li>01 March 2018 to 31 March 2018</li>
  <li>01 April 2018 to 23 April 2018</li>
  </ul>