40,590 views
7 votes
7 votes
What is the usage of "yield" in python?

User Stas Boyarincev
by
2.7k points

1 Answer

8 votes
8 votes

Answer:

Yield is a keyword in Python that is used to return from a function without destroying the states of its local variable and when the function is called, the execution starts from the last yield statement. Any function that contains a yield keyword is termed a generator. Hence, yield is what makes a generator.

Step-by-step explanation:

User Krzysztof Kozmic
by
3.0k points