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

How do I run a py file in python shell?

1 Answers  


What are the 3 types of relation?

1 Answers  


What are the two main data types in python?

1 Answers  


What are the differences between the threading and multiprocessing in python?

1 Answers  


How do you copy an object in python?

1 Answers  


Is python a pop or oop?

1 Answers  


What is the main use of python?

1 Answers  


What is lambda function in python?

1 Answers  


Can a set be sorted python?

1 Answers  


What is n in python?

1 Answers  


How many data types are there in python?

1 Answers  


Is there a double type in python?

1 Answers  


Categories