I was trying to learn how to use yield inside functions, but every time I added yield to the function I couldn't call it. I followed a tutorial and made this
def infinite_sequence():
num = 0
while True:
yield num
num += 1
but when I called
infinite_sequence()
it didn't work. It did work work when I took out yield. Stopped working when I added return. Started working again when took return. Why does this happen? Do you need to call on functions differently when you add in yield or return? Is it just repl?