Source Code:
(back to article)
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] squared_numbers = [x**2 if x % 2 == 0 else x for x in numbers] print(squared_numbers)
Result:
Report an issue