For starters I wrote a code for generator to initially grasp the context
def cycleoflife():
# use yield to create a generator
for i in range(0, 1000):
yield "eat"
yield "sleep"
yield "code"
which printed
eat
sleep
code
on every next call
But I want to try something different so wanted to implement generator I named Mary
such that it shows string like these on every next call:
I love Mary
Mary love that I love Mary
I love that Mary love that I love Mary
Mary love that I love that Mary love that I love Mary
I love that Mary love that I love that Mary love that I love Mary.....
def Mary():
for i in range(0, 1000):
yield "I love Mary"
yield "Mary love that"
yield "I love that"
love = Mary()
This is my code I keep getting stuck on how to concatenate my calls in a loop such that I get the above result.