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?..

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

Post New Answer

More Python Interview Questions

What is a docstring?

0 Answers  


How can you share variables across modules?

0 Answers  


Which software is best for python programming?

0 Answers  


What do (lambda) function closures capture in python?

0 Answers  


Can I use python to make a website?

0 Answers  






How can I represent an 'enum' in python?

0 Answers  


How can we pass optional or keyword parameters from one function to another in Python?

1 Answers  


How to overload constructors or methods in python?

0 Answers  


What is the best notepad?

0 Answers  


How many name spaces are defined in python?

0 Answers  


How many keywords are there in python?

0 Answers  


What is flatmap in python?

0 Answers  


Categories