LearnPy Hub
← Iterators & Generators problems
Hard

Iterator Class

Write a class EvenRange(n) implementing __iter__ and __next__ (raising StopIteration) that produces 0, 2, 4, ... below n. Print list(EvenRange(n)).

Input

One integer n ≥ 0.

Output

A list.

Sample 1

Input
10
Output
[0, 2, 4, 6, 8]

Sample 2

Input
0
Output
[]
solution.py
Output appears here
Iterator Class · Python practice problem · LearnPy Hub