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 coverage report?

0 Answers  


How will you merge two dictionaries in python?

0 Answers  


How do you use super in python?

0 Answers  


What is speech_recognition? Does this ship with python by default?

0 Answers  


What is the dogpile effect?

0 Answers  






How to find bugs or perform static analysis in a python application?

0 Answers  


What is variable length argument in function?

0 Answers  


Explain how to redirect the output of a python script from standout(ie., A monitor) on to a file?

0 Answers  


Explain the use of the split function in python?

0 Answers  


How do you reload a python module?

0 Answers  


How can I execute arbitrary python statements from c?

0 Answers  


Tell me what is pep 8?

0 Answers  


Categories