what does yield function do? what is the difference between return and yield?
Answer / siva kumar reddy dandu
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.
Is This Answer Correct ? | 0 Yes | 0 No |
What is a docstring?
How can you share variables across modules?
Which software is best for python programming?
What do (lambda) function closures capture in python?
Can I use python to make a website?
How can I represent an 'enum' in python?
How can we pass optional or keyword parameters from one function to another in Python?
How to overload constructors or methods in python?
What is the best notepad?
How many name spaces are defined in python?
How many keywords are there in python?
What is flatmap in python?