About 275,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. 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 allow looping within loops for more complex tasks.

  3. How to Use the repeat() Function in Python? - Python Guides

    Jan 4, 2025 · Learn how to use Python's `repeat()` function from the `itertools` module! This tutorial covers syntax, examples, and tips for repeating values in loops.

  4. How to Repeat N times in Python? (& how to Iterate?) - FavTutor

    Oct 25, 2022 · In this article, we've discussed how to repeat in Python and how it brought up the need for loops and functions. Further, we've learned about repeat() functions in python, offered by modules like itertools, pandas, and NumPy. Apart from them, we've also seen a trick to repeat strings n times in Python.

  5. Repeat-until or equivalent loop in Python - Stack Overflow

    Dec 15, 2017 · In repeat-until, the condition is evaluated at the end of the loop. So at least one iteration of the loop will always be executed before the end is reached and condition is evaluated.

  6. loops - Python: How to keep repeating a program until a specific …

    There are two ways to do this. First is like this: inp = raw_input() # Get the input. if inp == "": # If it is a blank line... break # ...break the loop. The second is like this: inp = raw_input() # Get the input again. Note that if you are on Python 3.x, you will need to replace raw_input with input.

  7. ForLoop - Python Wiki

    for loops are used when you have a block of code which you want to repeat a fixed number of times. The for-loop is always used in combination with an iterable object, like a list or a range. The Python for statement iterates over the members of a sequence in …

  8. 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 that stops the loop.

  9. SOLVED: How to loop n times in Python [10 Easy Examples]

    Jan 9, 2024 · First one is to iterate over the sequence like List, Tuple, Set and Dictionary. And the other one is to iterate over the range of numbers. This version of for loop will iterate over a sequence of numbers using the range () function.

  10. How to Repeat Code N Times in Python - Delft Stack

    Feb 14, 2021 · In this article, we’ve explored five methods to repeat a string of code N times in Python: using for loops, while loops, the itertools.repeat() function, list comprehension, and recursion. Each method has its use cases and advantages, so choose the one that best fits your requirements and coding style.

  11. Some results have been removed
Refresh