+ 10

I still couldn't understand the difference between using the return and yield statement. Could someone explain?

21st Jul 2016, 4:14 PM
Alonso
Alonso  - avatar
3 ответов
+ 14
Return is one time only. Yield works like a series of return statements, inside a generator.
24th Jul 2016, 7:09 PM
Ângelo Paulino
Ângelo Paulino - avatar
+ 5
I see so yield works same as return but just keeps returning values more than one time did I get it right?
25th Jul 2016, 6:27 AM
Alonso
Alonso  - avatar
+ 2
yes. if used with a loop calling it. if you call a generator once, the yield = return.
5th Aug 2016, 3:13 AM
scott williams
scott williams - avatar