28 lines
1.2 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

def format_names(names, numbering_type='default'):
"""
Функция форматирует список имён с выбранной нумерацией
Параметры:
names (list): список имён для форматирования
numbering_type (str): тип нумерации ('default' - обычная нумерация, любой другой символ - использование этого символа)
Возвращает:
str: отформатированную строку с именами
"""
result = '' # создаем пустую строку для результата
# проверяем тип нумерации
if not names:
return "Пустая запись"
if numbering_type == 'default':
# обычная нумерация
for i, name in enumerate(names, start=1):
result += f'{i}. {name}\n'
else:
# используем указанный символ
for name in names:
result += f'{numbering_type} {name}\n'
return result.strip() # убираем последний лишний перенос строки