About 4,000,000 results
Open links in new tab
  1. 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.

  2. python - for or while loop to do something n times - Stack Overflow

    Jul 15, 2013 · In Python you have two fine ways to repeat some action more than once. One of them is while loop and the other - for loop. So let's have a look on two simple pieces of code: …

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

  4. python - How to repeat a function n times - Stack Overflow

    Sep 9, 2011 · I'm trying to write a function in python that is like: def repeated(f, n): ... where f is a function that takes one argument and n is a positive integer. For example if I defined square …

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

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

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

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

    Feb 14, 2021 · Understanding how to repeat a specific operation N times allows you to streamline workflows and enhance productivity. This guide explores various methods, from classic for …

  10. How to call a Function N times in Python - bobbyhadz

    Apr 10, 2024 · Alternatively, you can use the itertools.repeat() class. This is a three-step process: Use a for loop to iterate over the iterator. Call the function on each iteration. def …

  11. Some results have been removed