About 21,700,000 results
Open links in new tab
  1. How can I return two values from a function in Python?

    I would like to return two values from a function in two separate variables. For example: loop = 1. row = 0. while loop == 1: print('''Choose from the following options?: 1. Row 1. 2. Row 2. 3. …

  2. Returning Multiple Values in Python - GeeksforGeeks

    May 2, 2023 · To return multiple values from a generator function, you can use the yield keyword to yield each value in turn. The generator function will then pause execution until the next …

  3. How to Return Multiple Values from a Function in Python?

    Feb 11, 2025 · Python provides several ways to return multiple values from a function. We will explore the most common methods, including returning tuples, lists, dictionaries, and using the …

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

    In python, you can have a function return multiple values. Here's a contrived example: quotient = x/y. remainder = x % y. return quotient, remainder . This seems very useful, but it looks like it …

  5. Alternatives for returning multiple values from a Python function

    In Python, the obvious way to do this is by means of a dict. Consider the following: y0 = x + 1. y1 = x * 3. y2 = y0 ** y3. return {'y0': y0, 'y1': y1 ,'y2': y2} (Just to be clear, y0, y1, and y2 are just …

  6. python - How to return 2 values from a function - Stack Overflow

    Dec 16, 2014 · Using return immediately exits a function. Meaning, the return leapyears line will never be reached because of the return sum + 366 line directly above it. If you want to return …

  7. Python: Return Multiple Values from a Function - datagy

    Oct 29, 2021 · Let’s take a look at how a function in Python is designed and how to return one value and how to return two values. return 'x' def return_two (): return 'x', 'y' In the example …

  8. Python function Return Multiple Values [SOLVED] - GoLinuxCloud

    Jan 9, 2024 · Python allows you to return multiple values by separating return values with commas. When multiple values are returned this way, they are actually packed into a single …

  9. How to return multiple values from a function in Python

    Apr 23, 2025 · In Python, you can return multiple values by simply separating them with commas in the return statement. For example, you can define a function that returns a string and an …

  10. How does Python return multiple values from a function?

    Sep 6, 2016 · Let's use a simpler function that returns multiple values: return a, b. You can look at the byte code generated by using dis.dis, a disassembler for Python bytecode. For comma …

Refresh