About 4,750,000 results
Open links in new tab
  1. python - What is the purpose of the return statement? How is it ...

    What does the return statement do? How should it be used in Python? How does return differ from print? See also Often, people try to use print in a loop inside a function in order to see …

  2. python: return, return None, and no return at all -- is there any ...

    Either all return statements in a function should return an expression, or none of them should. If any return statement returns an expression, any return statements where no value is returned …

  3. How can I return two values from a function in Python?

    If you want to return more than two values, consider using a named tuple. It will allow the caller of the function to access fields of the returned value by name, which is more readable.

  4. In Python, if I return inside a "with" block, will the file still close?

    Mar 27, 2012 · Consider the following: with open (path, mode) as f: return [line for line in f if condition] Will the file be closed properly, or does using return somehow bypass the context …

  5. how to return values in a python dictionary - Stack Overflow

    Feb 20, 2023 · A Python dictionary is a collection of Key-Value pairs, meaning that you have several items each with an "index" or "name" (the key) and a value (anything, in your case, lists)

  6. python - How can I use `return` to get back multiple values from a …

    Jul 4, 2020 · How can I use `return` to get back multiple values from a loop? Can I put them in a list? Asked 8 years, 4 months ago Modified 2 years, 11 months ago Viewed 188k times

  7. python - It is more efficient to use if-return-return or if-else-return ...

    Feb 8, 2012 · Since the return statement terminates the execution of the current function, the two forms are equivalent (although the second one is arguably more readable than the first). The …

  8. python - How can I get the return value of a function passed to ...

    Dec 1, 2016 · In the example code below, I'd like to get the return value of the function worker. How can I go about doing this? Where is this value stored? Example Code: import …

  9. python - Is it pythonic for a function to return multiple values ...

    However, when using Python for real-world applications, you quickly run into many cases where returning multiple values is necessary, and results in cleaner code. So, I'd say do whatever …

  10. function - Ignore python multiple return value - Stack Overflow

    Say I have a Python function that returns multiple values in a tuple: def func(): return 1, 2 Is there a nice way to ignore one of the results rather than just assigning to a temporary variabl...