Login
Задачка на питоне ноутпад
1617 просмотров
Перейти к просмотру всей ветки
in Antwort uscheswoi_82 30.07.22 00:32, Zuletzt geändert 30.07.22 01:49 (VornerX)
Ужс какой... я вам как художник художнику скажу... (с)
А так не легче?
with open('/home/me/some_names.txt') as f:
names = f.read().splitlines()
for i, group in enumerate([
names[names.index(n):names.index(n) + 5] for n in names
]):
with open(f'names_group_{i}.txt', 'w') as fw:
fw.writelines(' '.join(group))
No problem can be solved by the same kind of thinking that created it.