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

    Feb 5, 2021 · Create a function repeat and add your code in it. Then use while True to call it infinitely or for i in range(6) to call it 6 times: import requests def repeat(): addr = input() vendor …

  2. 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.

  3. 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 …

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

    Oct 25, 2022 · Learn how to repeat n times in python using loops and functions. Also, how do you iterate n times in python?

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

    Feb 16, 2023 · There are two ways you can repeat a function in Python: Use the for loop to repeat a function N times; Use the while loop to repeat a function indefinitely; This tutorial will show …

  6. ForLoop - Python Wiki

    There are two ways to create loops in Python: with the for-loop and the while-loop. for loops are used when you have a block of code which you want to repeat a fixed number of times. The …

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

    Aug 7, 2022 · 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 …

  8. Easily Repeat Tasks Using Loops - OpenClassrooms

    Loops let you easily repeat tasks or execute code over every element in a list. A for loop enables you to repeat code a certain amount of time. A while loop lets you repeat code until a certain …

  9. 6 Python Techniques to Call a Function N Times

    In this article, we’ll take a closer look at six different approaches to calling a function N times in Python, including the use of range(), itertools.repeat(), list comprehension, for loop, map(), and …

  10. Repeating a function in Python - Stack Overflow

    Feb 6, 2014 · If you want to repeat something n times try using a for loop (read more here). for x in range(3): # This code will execute 3 times print("Executed {0} times".format(x+1))

  11. Some results have been removed
Refresh