pychallenger

pychallenger

  • Dashboard
  • Python Basics
  • Intermediate Python
  • Basic Data Analysis
  • Login
Home Intermediate Python
Generators

Generators

generators
yield
generator expression
yield from
lazy iteration
iterators
next
NEXT

Introduction to generators and yield

LESSON

Exercise: Yield three numbers

CHALLENGE

Exercise: Yield squares with a loop

CHALLENGE

Exercise: Pull values out with next()

CHALLENGE

Exercise: Yield only even numbers

CHALLENGE

Generator expressions

LESSON

Exercise: Turn a list comprehension into a generator

CHALLENGE

Exercise: Sum of squares with a generator expression

CHALLENGE

Exercise: Count items that match a condition

CHALLENGE

yield from and chaining generators

LESSON

Exercise: Flatten lists with yield from

CHALLENGE

Exercise: Chain two generators

CHALLENGE
Links
Blog Pricing Sign Up
Social
Twitter YouTube LinkedIn
Imprint Privacy Policy Terms
Copyright © 2026 Erik Nogueira Kückelheim