#C14275. Square List Elements Using List Comprehension
Square List Elements Using List Comprehension
Square List Elements Using List Comprehension
Given a list of integers, your task is to generate a new list where every integer \(x\) is replaced by its square \(x^2\). The transformation must be performed using list comprehensions (or their equivalent in other languages).
If the input list is empty, your program should produce no output.
inputFormat
The input consists of a single line containing zero or more integers separated by spaces.
Example: 1 2 3 4
outputFormat
The output should be a single line of integers where each integer is the square of the corresponding integer from the input, separated by a space.
Example: If the input is 1 2 3 4
, the expected output is 1 4 9 16
.
1 2 3 4
1 4 9 16