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 |
How can you pick a random item from a list or tuple in python?
Should I learn javascript or python?
What are the attributes?
What is sys stdout flush ()?
What is the language from which Python has got its features or derived its features?
What makes python object-oriented?
How do you use enums in Python?
What is the output of print str + “test” if str = ‘hello world!’?
What is the with statement in python?
Specify the differences between pyramid, django, and flask.
What is the difference between = and == in python?
Tell us what is python? What are the benefits of using python?