Source Code:
(back to article)
def squares(n): for i in range(1, n + 1): yield i ** 2 def nested_squares(n): yield from squares(n) for square in nested_squares(10): print(square) # Output: # 1 # 4 # 9 # 16 # 25 # 36 # 49 # 64 # 81 # 100
Result:
Report an issue