Q:

Code block doesn't return all values?

I cannot work this out and need help to understand why when returning within the following code block it only outputs the first list within the date_list and not the same as the print statement?
date_list = [['2015-11-11', '2015-12-02'], ['2016-04-03', '2016-04-15'], ['2016-05-10', '2016-05-22']]

def formatdates():
    for i in range(len(date_list)):
        start_date = date_list[i][0]
        end_date = date_list[i][1]
        s = datetime.strptime(start_date, "%Y-%m-%d")
        e = datetime.strptime(end_date, "%Y-%m-%d")
        formatted_s = s.strftime("%e-%b-%Y")
        formatted_e = e.strftime("%e-%b-%Y")
        i += 1
        print("{} to {}".format(formatted_s, formatted_e))  # Output 1 below
        return print("{} to {}".format(formatted_s, formatted_e))  # Output 2 below
print(formatdates())

The desired outcome is to output the lists of formatted dates as per the print statement when returned within the function?
How can I return all the lines as a printed list?

Output 1:
11-Nov-2015 to  2-Dec-2015
3-Apr-2016 to 15-Apr-2016
10-May-2016 to 22-May-2016
Output 2:
11-Nov-2015 to  2-Dec-2015

A:

date_list = [['2015-11-11', '2015-12-02'], ['2016-04-03', '2016-04-15'], ['2016-05-10', '2016-05-22']]

def formatdates():
    ret_date = []
    for d in date_list:
        start_date = d[0]
        end_date = d[1]
        s = datetime.strptime(start_date, "%Y-%m-%d")
        e = datetime.strptime(end_date, "%Y-%m-%d")
        formatted_s = s.strftime("%e-%b-%Y")
        formatted_e = e.strftime("%e-%b-%Y")
         # print("{} to {}".format(formatted_s, formatted_e))  
        ret_date.append("{} to {}".format(formatted_s, formatted_e))
    return ret_date
print(formatdates())

UPDATE : return was inside the loop and makes function to exit after first step.

