what does yield function do? what is the difference between return and yield? - Just Crack Interview

what does yield function do? what is the difference between return and yield?

what does yield function do? what is the difference between return and yield?

Ques:- what does yield function do? what is the difference between return and yield?
1 1381

One Answer on this Question

  1. Yield function keeps all single return values and return all at a time as a list
    Yield and return both are used for returning the values from function.
    Generally yield is used with iterators, So yield will keep all the return values of each iterative call and returns final result at the end of call as List where as return can return one value for each function call.

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top