$ ./guess_the_languageProblem Solving — fill the blank
Problem Solving — fill the blank · hard · #131

Fill in the blank

# returns a generator yielding squares of nums
def squares(nums):
    for n in nums:
        ____ n * n
# list(squares([1,2,3])) -> [1,4,9]

Answer: yield (also accepted: yield, yield())

yield turns the function into a generator that produces each square.
Play Problem Solving ▸