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

    The return statement causes your function to exit and hand back a value to its caller. The point of functions in general is to take in inputs and return something. The return statement is used when a …

  2. python - How do I get ("return") a result (output) from a function? How ...

    Suppose I have a function like: def foo(): x = 'hello world' How do I get the function to return x, in such a way that I can use it as the input for another function or use the variable within...

  3. python - SyntaxError: 'return' outside function - Stack Overflow

    Feb 19, 2017 · The return function is used to pass a value back to where a certain function is called. The way I see it, you're essentially trying to overwrite the return value. You should use it in a function that …

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

    Using return None This tells that the function is indeed meant to return a value for later use, and in this case it returns None. This value None can then be used elsewhere. return None is never used if …

  5. Creating a new function as return in python function?

    Oct 5, 2012 · Python may return functions from functions, store functions in collections such as lists and generally treat them as you would any variable. Cool things such as defining functions in other …

  6. function - Which Python Conditional Return Statement Is The Most ...

    Nov 4, 2014 · Which of the following is the proper way to return something with Python when using conditionals? Does it matter? And why? # OPTION 1 if conditional: return a else: return b # OPTION 2 if

  7. 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. You can still access …

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

    Python's handling of method arguments necessitates the ability to directly return multiple values. In C++, for example, method arguments can be passed by reference, so you can assign output values to …

  9. python - Is there a way to do more work after a return statement ...

    Jul 23, 2012 · From the docs for return: return leaves the current function call with the expression list (or None) as return value. You may want to look into generator functions and the yield statement, this is …

  10. python - How to stop a function - Stack Overflow

    A simple return statement will 'stop' or return the function; in precise terms, it 'returns' function execution to the point at which the function was called - the function is terminated without further action.