About 220,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 - How do I get ("return") a result (output) from a function?

    We can make a tuple right on the return line; or we can use a dictionary, a namedtuple (Python 2.6+), a types.simpleNamespace (Python 3.3+), a dataclass (Python 3.7+), or some other …

  3. 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 …

  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 use return in Python - Stack Overflow

    Apr 6, 2014 · The return ends the function's control straightaway and returns a value without having to go through the rest of the function's code. The first method however is slightly slower …

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

    Often in Python, functions which return None are used like void functions in C -- Their purpose is generally to operate on the input arguments in place (unless you're using global data (shudders)).

  7. python - What is the formal difference between "print" and "return ...

    Dec 11, 2017 · Edit: as pointed by others, if you are in an interactive python shell you see the same effect (the value is printed), but that happens because the shell evaluates expressions …

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

    Jul 4, 2020 · This question has become a canonical duplicate target for questions about returning multiple values from code including a for loop. As such, I have edited it somewhat artificially, to …

  9. python - What does 'Return' do exactly, and where and when …

    Aug 15, 2018 · What's the difference between where I put the 'return'? It gives me a different answer and I'm really confused. When you call return, you end the function and return …

  10. Difference between returns and printing in python? [duplicate]

    The Point return is not a function. It is a control flow construct (like if else constructs). It is what lets you "take data with you between function calls". Break down print: gives the value to the …

Refresh