/
Kirby
/
Iterators.Generators.Yield
Обзор
Документация
Войти
/
Kirby
/
Iterators.Generators.Yield
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
task2.py
27 строк
704 B
Alex
Initial commit
20 май 2026, 21:39
20 май 2026, 21:39
2966c34
Код
Авторство
О чём код?
import types def flat_generator(list_of_lists): for sublist in list_of_lists: for item in sublist: yield item def test_2(): list_of_lists_1 = [ ['a', 'b', 'c'], ['d', 'e', 'f', 'h', False], [1, 2, None] ] for flat_iterator_item, check_item in zip( flat_generator(list_of_lists_1), ['a', 'b', 'c', 'd', 'e', 'f', 'h', False, 1, 2, None] ): assert flat_iterator_item == check_item assert list(flat_generator(list_of_lists_1)) == ['a', 'b', 'c', 'd', 'e', 'f', 'h', False, 1, 2, None] assert isinstance(flat_generator(list_of_lists_1), types.GeneratorType) if __name__ == '__main__': test_2()