def excel_file_name_updater(dates, flight_numbers):
    """Takes a list of dates and a list of flight numbers and returns a list of names"""
    flight_names = []
    if len(dates) == len(flight_numbers):
        for flight in range(len(dates)):
            date = str(dates[flight])
            if len(date) != 8:
                raise Exception(
                    'The date is in an incorrect format. Format should be YYYYMMDD. date = {}'
                    .format(date))
            year = date[:4]
            month = date[4:6]
            day = date[6:]
            try:
                int(year)
                year_available = True
            except ValueError:
                year_available = False
            try:
                int(month)
                month_available = True
            except ValueError:
                month_available = False
            try:
                int(day)
                day_available = True
            except ValueError:
                day_available = False
            if len(month) < 2:
                month = '0' + month
            if len(day) < 2:
                day = '0' + day
            if len(year) < 4:
                year = '20' + year
            flight_date = int((year + month + day).replace('\n', ''))
            try:
                flight_number = str(flight_numbers[flight])
                flight_number_available = True
                if '.' in str(flight_numbers):
                    flight_number = str(flight_number).replace('.', '_')
                    multiple_autopilots = True
                else:
                    multiple_autopilots = False
                if multiple_autopilots is False:
                    if len(str(flight_number)) < 2:
                        flight_number = '0' + str(flight_number)
                else:
                    if '_' not in str(flight_number):
                        flight_number = str(flight_number) + '_'
                    if len(str(flight_number).split('_')[0]) < 2:
                        flight_number = '0' + str(flight_number)
                    if len(str(flight_number).split('_')[1]) < 1:
                        flight_number = str(flight_number) + '0'
            except ValueError:
                flight_number_available = False
            if (year_available and month_available and day_available) is True:
                text = str(flight_date) + '_Flight'
                if flight_number_available is True:
                    text += str(flight_number)
                else:
                    raise Exception('Error',
                        'Flight number is required for the automatic generation of the excel file name.'
                        )
                    text = ''
            else:
                raise Exception('Error',
                    'The complete flight date is required for the automatic generation of the excel file name.'
                    )
                text = ''
            if text == '':
                return
            flight_names.append(text)
        global generated_file_name
        generated_file_name = flight_names
    else:
        raise IndexError(
            'Number of dates does not match the number of flights. Check the Input_file.json to make sure the lists are of the same length. len(dates) = {}, len(flight_numbers) = {}'
            .format(len(dates), len(flight_numbers)))
    return generated_file_name
