first commit
This commit is contained in:
commit
9615165024
21 files changed
+404
No files matched your search
@@ -0,0 +1,17 @@
|
||||
class Squares:
|
||||
def __init__(self, max_value):
|
||||
self.n = 1
|
||||
self.max_value = max_value
|
||||
|
||||
def __next__(self):
|
||||
if self.n >= self.max_value:
|
||||
raise StopIteration
|
||||
self.n +=1
|
||||
return self.n * self.n
|
||||
|
||||
def __iter__(self):
|
||||
return self
|
||||
|
||||
s = Squares(5)
|
||||
for i in s:
|
||||
print(i)
|
||||
Reference in new issue
Block a user