New: Intelligent Flashcards spaced-repetition decks for every topic, built to make things actually stick.
You have result = [] followed by for x in nums: result.append(x ** 2). Which one-liner is the idiomatic replacement?
result = []
for x in nums: result.append(x ** 2)
[nums.map(x ** 2)]
[for x in nums: x ** 2]
[x ** 2 for x in nums]