Kodewick
Start learning →
Starter→0 / 80

Square them all

#001StarterComprehensionsLists3 min

There is a row of numbers in the notebook. Write squares(nums) to return a new list of each number squared, in the same order. Try it in one line: a list comprehension.

Examples
squares([1, 2, 3])→[1, 4, 9]
squares([])→[]
main.py
def squares(nums):
    # your code here: a list comprehension that turns each n into n * n
    return []
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.