What is yield in Python 2024?
I'll answer
Earn 20 gold coins for an accepted answer.20
Earn 20 gold coins for an accepted answer.
40more
40more
Studied at the University of Zurich, Lives in Zurich, Switzerland.
Yield. Yield is a keyword that is used like return , except the function will return a generator. Here it's a useless example, but it's handy when you know your function will return a huge set of values that you will only need to read once. Then, your code will be run each time the for uses the generator.
2023-05-05 06:13:06
评论(499)
Helpful(122)
Helpful
Helpful(2)

Amelia Collins
QuesHub.com delivers expert answers and knowledge to you.
Yield. Yield is a keyword that is used like return , except the function will return a generator. Here it's a useless example, but it's handy when you know your function will return a huge set of values that you will only need to read once. Then, your code will be run each time the for uses the generator.