About 1,210,000 results
Open links in new tab
  1. python - Where to use the return statement with a loop? - Stack Overflow

    Instead, you can control the behaviour of the for loop independently from the function itself using break. In addition, you can have multiple return statements in a function depending on what …

  2. break, continue, and return :: Learn Python by Nina Zakharenko

    break, continue, and return. break and continue allow you to control the flow of your loops. They’re a concept that beginners to Python tend to misunderstand, so pay careful attention. …

  3. The Python return Statement: Usage and Best Practices

    In this tutorial, you’ll learn that: You use return to send objects from your functions back to the caller code. You can use return to return one single value or multiple values separated by …

  4. Python return statement - GeeksforGeeks

    Dec 10, 2024 · Python allows you to return multiple values from a function by returning them as a tuple: Example: In this example, the fun () function returns two values: name and age. The …

  5. Python For Loops - W3Schools

    With the for loop we can execute a set of statements, once for each item in a list, tuple, set etc. Print each fruit in a fruit list: The for loop does not require an indexing variable to set …

  6. Mastering the ‘For Loop Return’ Statement in Python – A …

    In this blog post, we will explore the ‘for loop’ in Python and understand the importance and usage of the ‘return’ statement within the loop. The ‘for loop’ is a control flow statement that iterates …

  7. returning values in for loop - Python Forum

    Dec 17, 2020 · If you want multiple values, you have to return it in a collection object of some sort (list, tuple, set, dict, etc.) In your example, you could return the list directly, or you could return …

  8. Python For Loop: Syntax, Examples & Use Cases

    Learn Python for loop from scratch! This comprehensive guide covers syntax, iterating sequences, range(), enumerate(), break/continue, real-world examples & more.

  9. Python Language Tutorial => Return statement inside loop in a …

    for value in params: print ('Got value {}'.format(value)) if value == 1: # Returns from function as soon as value is 1. print (">>>> Got 1") return. print ("Still looping") return "Couldn't find 1" Got …

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

    Jul 4, 2020 · Append your data to a list, then return it after the end of your loop: def show_todo(): my_list = [] for key, value in cal.items(): my_list.append((value[0], key)) return my_list Or use a …

Refresh