Walrus & Conditional Logic
Completed
Read a line of integers. Using a list comprehension with the walrus operator, keep the values whose square is greater than 20, storing each square only once; print the squares.
Input
One line of integers.
Output
One line.
Example
Input
1 5 -6 3 10
Output
25 36 100
Editor
Python
Hints
(name := expression) assigns and returns a value inside an expression.
Solution explanation
The walrus operator avoids computing x * x twice.
Show solution
nums = map(int, input().split())
print(*[sq for x in nums if (sq := x * x) > 20])