Skip to content

Instantly share code, notes, and snippets.

@accessnash
Created March 21, 2021 08:28
Show Gist options
  • Save accessnash/3a2ced514ae31292b796d6f9a6e56004 to your computer and use it in GitHub Desktop.
Save accessnash/3a2ced514ae31292b796d6f9a6e56004 to your computer and use it in GitHub Desktop.
# -*- 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