1. Learn
  2. /
  3. Courses
  4. /
  5. Intermediate Object-Oriented Programming in Python

Connected

Exercise

Creating a Lottery iterator

You've practiced building an iterator, and handling StopIteration exceptions when using an iterator. Now, it's time to put it all together. You'll be building a Lottery iterator to draw integers at random and create a winning number. Happy coding!

Instructions 1/3

undefined XP
    1
    2
    3
  • Define a magic method that returns a reference to the object, making the Lottery class an iterator.