About 392 results
Open links in new tab
  1. python - Return statement on multiple lines - Stack Overflow

    Sep 1, 2013 · Most likely, you want a line break in the string you're returning, not in the return statement itself. That can be done with '\n'. In python, an open paren causes subsequent lines to be considered …

  2. How to Add Line Breaks in Python Return Statements Without Errors: …

    Jan 29, 2026 · This guide will walk you through **four safe methods** to add line breaks in `return` statements, explain common pitfalls to avoid, and share best practices to keep your code clean and …

  3. Return Statements and Multi - line Code in Python - CodeRivers

    Mar 28, 2025 · Multi - line code, on the other hand, allows us to write more complex statements or blocks of code in a more organized way. This blog post will delve into these topics, providing a …

  4. Multi-Line Statements in Python - GeeksforGeeks

    Jun 30, 2025 · In Python, a statement (logical command or an instruction) usually ends at the end of a line. But sometimes, your code is too long and needs to be split into multiple lines to make it easier to …

  5. How to Return Multiple Lines in Python's __str__ Method

    Learn how to effectively use the `__str__` method in Python to return multiple lines in your output for better readability. ---...more

  6. python - Returning output in multiple lines - Stack Overflow

    Jun 14, 2020 · I want to return the output in one line below the other instead of all in the same line for my code def f (a,b): return a,b f (2,3) So rather than in tuple form I want to return an output like: ...

  7. How to return more than one value over multiple lines

    Apr 7, 2016 · What do you want? Do you want the return value to be a tuple and display it differently, or do you want the return value to be a string with a linebreak?

  8. Mastering Multiple Line Printing in Python - codegenes.net

    Nov 14, 2025 · The most straightforward way to print multiple lines in Python is by using the newline character \n. This character represents a line break, and when placed within a string, it causes the …

  9. python - Can I return several lines using __str__? - Stack Overflow

    May 7, 2021 · How can I use `return` to get back multiple values from a loop? Can I put them in a list? (2 answers)

  10. python - How to write the return in multiple lines - Stack Overflow

    Aug 10, 2022 · It is hard to see all the contents in the Jupyter Notebook Cell as the return will display in a single line. The following code is trying to split the return items: