LoslegenKostenlos loslegen

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!

Diese Übung ist Teil des Kurses

Intermediate Object-Oriented Programming in Python

Kurs anzeigen

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

class Lottery:
  def __init__(self, number_digits):
    self.number_digits = number_digits
    self.counter = 0
  
  # Create an iterator using a magic method
  def ____(____):
    return ____
Code bearbeiten und ausführen