Squares with a Comprehension
Completed
Read n and print the list of squares of 1..n built with a list comprehension.
Input
One integer.
Output
The list.
Example
Input
5
Output
[1, 4, 9, 16, 25]
Editor
Python
Hints
[expression for item in iterable] builds a list.
Solution explanation
A comprehension is a compact loop that produces a list.
Show solution
n = int(input())
print([i * i for i in range(1, n + 1)])