(start, end)
return months
Given a start date and enddate return all months between them.
    Returns a list of (Year, month) tuples, the first one being
    the year and month of the start date, and the last one being
    the year and month of the end date.
Given a start date and enddate return all months between them.
    Returns a list of (Year, month) tuples, the first one being
    the year and month of the start date, and the last one being
    the year and month of the end date.
Given a start date and enddate return all months between them . Returns a list of ( Year month ) tuples the first one being the year and month of the start date and the last one being the year and month of the end date .
def months_between(start, end):
    """
    Given a start date and enddate return all months between them.
    Returns a list of (Year, month) tuples, the first one being
    the year and month of the start date, and the last one being
    the year and month of the end date.
    """
    assert datetime.date(start.year, start.month, 1) <= datetime.date(end.year, end.month, 1), \
        'start date {} was later than end date {}!'.format(start, end)
    months = []
    date_type = type(start)
    while start <= end:
        months.append((start.year, start.month))
        (yearnext, monthnext) = add_months(start.year, start.month, 1)
        start = date_type(yearnext, monthnext, 1)
    return months
def months_between ( start , end ) : assert datetime . date ( start . year , start . month , 1 ) <= datetime . date ( end . year , end . month , 1 ) , 'start date {} was later than end date {}!' . format ( start , end ) months = [ ] date_type = type ( start ) while start <= end : months . append ( ( start . year , start . month ) ) ( yearnext , monthnext ) = add_months ( start . year , start . month , 1 ) start = date_type ( yearnext , monthnext , 1 ) return months