LearnPy Hub
← Iterators & Generators problems
Easy

list() of a Generator

Write a generator squares(n) yielding 1², 2², …, n². Read n and print list(squares(n)).

Input

One integer n ≥ 1.

Output

A Python list.

Sample 1

Input
4
Output
[1, 4, 9, 16]

Sample 2

Input
1
Output
[1]
solution.py
Output appears here
list() of a Generator · Python practice problem · LearnPy Hub