About 5,710,000 results
Open links in new tab
  1. How to repeat a while loop a certain number of times

    Jan 13, 2018 · To repeat something for a certain number of times, you may: Use range or xrange. for i in range(n): # do something here Use while. i = 0 while i < n: # do something here i += 1 If …

  2. python - How do you repeatedly add a specific value to a …

    Apr 5, 2019 · To print out a combination of strings and variables, use a python fstring (python 3.6 and higher). print(f"Year {x+1}, {weight}") will do it. Hope that helps Dell.

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

  4. How would I add something to a number over and over again in Python

    Oct 13, 2020 · You can do this: you are not updating the x so you keep adding the originalx value. so x have to be updated. but since you have y you can do this. y = 0 mylist = [] for i in range …

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

    Jan 4, 2025 · The repeat () function in Python’s module allows you to create an iterator that repeats an object a specified number of times or infinitely. The syntax is: where: times …

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

    Feb 14, 2021 · This article discusses five distinct methods to repeat a specific operation a predetermined number of times in Python, ranging from classic for loops to more advanced …

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

    Oct 25, 2022 · The repeat() function is the function that will actually let you repeat the code n number of times in python. 01) Using itertools.repeat() The itertools module provides a …

  8. Python | Add similar value multiple times in list - GeeksforGeeks

    Apr 17, 2023 · Adding a single value in list is quite generic and easy. But to add that value more than one time, generally, a loop is used to execute this task. Having shorter tricks to perform …

  9. How to increment in Python - Altcademy Blog

    Jun 13, 2023 · A common use case for incrementing is when you need to perform a specific action a certain number of times. In this case, you can use a loop to increment a variable. In …

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

    Feb 16, 2023 · To repeat a function N times in Python, you need to use the for loop and range function. Suppose you have a function that asks for a number and then multiple that number …