what does yield function do? what is the difference between return and yield?
Answer Posted / 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 View All Answers
When should you use generator expressions vs. list comprehensions in Python and viceĀversa?
What is os module will do in python?
Can you sort a string in python?
What is set () in python?
How do we execute python?
Write a small code to explain repr() in python ?
What are tokens in python?
What is a generator?
Write a regular expression that will accept an email id. Use the re module.
What is the use of dir() function?
What are different ways to create an empty numpy array in python?
Do arrays start at 0 in python?
What is static in python?
How long does it take to learn python?
What is Python Decorator?