Created
March 21, 2021 08:28
-
-
Save accessnash/3a2ced514ae31292b796d6f9a6e56004 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Spyder Editor | |
This is a temporary script file. | |
""" | |
class RandomNumbers: | |
def __init__(self, length, *, range_min = 0, range_max = 20): | |
self.length = length | |
self.range_min = range_min | |
self.range_max = range_max | |
self.num_requested = 0 | |
def __len__(self): | |
return self.length | |
def __next__(self): | |
if self.num_requested >= self.length: | |
raise StopIteration | |
else: | |
self.num_requested += 1 | |
return random.randint(self.range_min, self.range_max) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment