โ† Python
#5 most askedVery commonEasyPythonic code

List comprehensions

๐Ÿข Asked in real interviews
No reports yet. Were you asked this? Be the first to say where.
I was asked this

Using a comprehension, write squares_of_evens(nums) returning the squares of the even numbers, in order. Then explain when not to use comprehensions.

๐Ÿงช Practice

Write your solution, then press Run tests. Explain your approach out loud as you go.

Python
def squares_of_evens(nums):
    pass

Output appears here. Press Run or Ctrl/โŒ˜ + Enter.

Try it first. Struggling for a few minutes is how it sticks.