About 27,900,000 results
Open links in new tab
  1. python - How do I write a loop to repeat the code? - Stack Overflow

    Feb 5, 2021 · You can create a variable, and then say that as long as the variable is true to its value, to repeat the code in the for loop.

  2. How to repeat a function N times or indefinitely in Python

    Feb 16, 2023 · To repeat a function indefinitely in Python, you need to use the while loop and call the function in that loop. To stop the function, you need to write an if statement with a condition …

  3. How do I make a whole program repeat itself? : r/learnpython - Reddit

    Oct 29, 2022 · If you want to loop the entire program, indent the entire program so it's in the loop. The better solution is to stick the entire program in a function, then call the function in the loop, …

  4. How to Create Loops in Python (With Examples) - wikiHow

    Feb 20, 2025 · In Python, and many other programming languages, you will need to loop commands several times, or until a condition is fulfilled. It is easy, and the loop itself only …

  5. Loops and Repeating Code – Stephen Marz - University of …

    Be able to repeatedly execute a block of code until a certain condition is met. Be able to prematurely break a loop using the break keyword. Understand what constitutes as an infinite …

  6. Loops in Python – For, While and Nested Loops - GeeksforGeeks

    Mar 8, 2025 · Loops in Python are used to repeat actions efficiently. The main types are For loops (counting through items) and While loops (based on conditions). Additionally, Nested Loops …

  7. python - Is there a way to make a while loop repeat itself?

    Jan 24, 2022 · You could either place the whole thing in a while loop or create a function such as below and call the function if your repeat condition is met. This has the added bonus of your …

  8. Enki | Blog - How to Repeat Code in Python

    Repeating code in Python using for loops is both powerful and simple, making your code more readable and maintainable. You can iterate over various data structures such as lists, tuples, …

  9. Easily Repeat Tasks Using Loops - OpenClassrooms

    A while loop lets you repeat code until a certain condition is met. Loops are great to help you repeat code easily. Next, we’ll dive into functions; another way to help you bundle repeatable …

  10. if statement - python repeat program while true - Stack Overflow

    Sep 24, 2012 · Assign a bool value to a variable called playing, and then use that as the loop condition. So you would have; playing = True while playing: choice = input("would you like to …

  11. Some results have been removed
Refresh