-
-
Save picanumber/d8638d51ba5eb6eb3bf2 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
class CustomRange: | |
def __init__(self, max): | |
self.max = max | |
def __iter__(self): | |
self.curr = 0 | |
return self | |
def next(self): | |
numb = self.curr | |
if self.curr >= self.max: | |
raise StopIteration | |
self.curr += 1 | |
return numb | |
for i in CustomRange(10): | |
print i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment