List of squares

Read n and print the list of squares from 1 to n squared, using one list comprehension.

What to build

A list built from a range in one line.

Requirements

  • Read n.
  • Build the list of squares with one comprehension, and print it.

Input

One whole number n from 1 to 100.

Output

The list, printed with print(), for example [1, 4, 9].

Constraints

n is from 1 to 100.

Example

Input:

3

Output:

[1, 4, 9]

Why it works

range(1, n + 1) supplies the numbers and the expression at the front decides what each one becomes.

Examples

Example 1 · Input
3
Expected output
[1, 4, 9]
Example 2 · Input
1
Expected output
[1]

Prompts inside input() are ignored when checking, so input("n: ") is fine.

Hints

Hint 1

[i * i for i in range(1, n + 1)] builds the whole list.

Solution

Show one correct solution (try it yourself first)
n = int(input())
print([i * i for i in range(1, n + 1)])

Lesson: List comprehensions →