9951 explained code solutions for 126 technologies


pythonHow to yield


def squares():
  x = 0
  while x < 5:
    x = x + 1
    yield x*xctrl + c
def squares()

name of the generator function to yield something

while x < 5

we'll yield some values until x is 5

x = x + 1

increment x

yield x*x

yields square of x