Last active
October 30, 2017 02:42
-
-
Save cvno/65e6ff8a64212f1841bb44dd6c7f080a 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 Range: | |
def __init__(self,stop,start=0): | |
self.start=start | |
self.stop=stop | |
def __iter__(self): | |
return self | |
def __next__(self): | |
if self.start > self.stop-1: | |
raise StopIteration | |
n=self.start | |
self.start+=1 | |
return n | |
r=Range(10) | |
for i in r: | |
print(i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment