Skip to content

Instantly share code, notes, and snippets.

@AyemunHossain
Created February 26, 2022 10:06
Show Gist options
  • Save AyemunHossain/749caef33a26284c2100e2185e76a5bd to your computer and use it in GitHub Desktop.
Save AyemunHossain/749caef33a26284c2100e2185e76a5bd to your computer and use it in GitHub Desktop.
Implement Your Own Range Function
class NewRange:
current = 0
def __init__(self, first, last):
self.first = first
self.last = last
def __iter__(self):
return self
def __next__(self):
if NewRange.current<self.last:
NewRange.current +=1
return (NewRange.current-1)
raise StopIteration
rng = NewRange(1,200)
for i in rng:
print(i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment