/
gntshka
/
OpenReadWriteInFile
Обзор
Документация
Войти
/
gntshka
/
OpenReadWriteInFile
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Task 3/Story.py
24 строки
576 B
Ignat M
First commit
10 апр 2025, 15:51
10 апр 2025, 15:51
fa71457
Код
Авторство
О чём код?
all_lists = [] def read_file(name_file, name_list): with open(name_file, encoding='utf-8') as f: name_list = f.readlines() name_list.insert(0, f'{len(name_list)}\n') name_list.insert(0, f'{name_file}\n') name_list.append('\n') all_lists.append(name_list) read_file('1.txt', 'txt_1') read_file('2.txt', 'txt_2') read_file('3.txt', 'txt_3') all_lists = sorted(all_lists, key=len) one_list = [] for i in all_lists: one_list += i with open('homework.txt', 'w', encoding='utf-8') as f: for i in one_list: f.write(i)