logo

Crowdly

If I was to loop over this Iterator, how many times would it iterate? class Numb...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

If I was to loop over this Iterator, how many times would it iterate?

class NumberIterator:

    def __init__(self):

        self.current = 1

        

    def __iter__(self):

        return self

        

    def __next__(self):

        if self.current > 10:

            raise StopIteration()

        

        next_item = self.current

        self.current += 2

        return next_item
0%
100%
0%
0%
More questions like this

Want instant access to all verified answers on learning.monash.edu?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!