All Challengesintermediate

Python list comprehension

Python list comprehensions are dense but powerful. AI generates them everywhere.

pythonlist comprehensionarraysfiltering
python
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

evens = [n for n in numbers if n % 2 == 0]
squares_of_evens = [n ** 2 for n in numbers if n % 2 == 0]
words = ['hello', 'world', 'python']
upper = [w.upper() for w in words]

Question

What are the values of evens, squares_of_evens, and upper?