Challenge: Chaining and Composing Iterators
Glissez pour afficher le menu
Tâche
Glissez pour commencer à coder
Implement the function chained_odds_squared(numbers) that chains together the provided generator functions to process a sequence of numbers:
-
First, use the
filter_oddsgenerator to filter out even numbers from the input iterablenumbers. -
Then, use the
square_numbersgenerator to yield the square of each remaining (odd) number. -
Your function should return an iterator that yields the squared values of odd numbers from the input.
-
Do not create intermediate lists.
Solution
Tout était clair ?
Merci pour vos commentaires !
Section 5. Chapitre 7
Demandez à l'IA
Demandez à l'IA
Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion
Section 5. Chapitre 7