Search⌘ K
AI Features

Challenge: Iterables and Iterators

Explore how to implement and use custom iterator classes in Python by creating a Fibonacci sequence iterator and a cycling iterator that repeats elements. Learn how to manage iteration limits and handle StopIteration exceptions.

We'll cover the following...

Problem 1

In this problem, you’re required to produce the numbers in the Fibonacci series. Write an iterator class Fibonacci that takes a number n and creates the first n Fibonacci numbers.

This the Fibonacci sequence: 0,1,1,2,3,5,8,13,21,34,...0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ... ...