About 36,400,000 results
Open links in new tab
  1. Are infinite for loops possible in Python? - Stack Overflow

    The quintessential example of an infinite loop in Python is: while True: pass To apply this to a for loop, use a generator (simplest form): def infinity(): while True: yield This can be used as …

  2. Create an infinite loop in Python - CodeSpeedy

    You can create an infinite loop through any method (for or while) by not writing the termination condition or making a termination condition so the loop can never achieve it. For example, in a …

  3. loops - Looping from 1 to infinity in Python - Stack Overflow

    Jun 27, 2014 · If you want to use a for loop, it's possible to combine built-in functions iter (see also this answer) and enumerate for an infinite for loop which has a counter. We're using iter to …

  4. Infinite loops using 'for' in Python - Stack Overflow

    Jan 11, 2018 · For loops are iterating through elements of a generator. You can write an infinite generator using the yield keyword though. range is a class, and using in like e.g. range(1, a) …

  5. Python while loop (infinite loop, break, continue, and more)

    Aug 18, 2023 · Infinite loops with counters and similar use cases can often be written more easily using these functions. A while loop in Python is written as follows: You can specify multiple …

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

    Mar 8, 2025 · If we want a block of code to execute infinite number of times then we can use the while loop in Python to do so. The code given below uses a ‘while’ loop with the condition …

  7. What is Infinite Loop in Python? | Scaler Topics

    May 8, 2024 · There are various types of infinite loops in Python such as: while statement. if statement. break statement. continue statement. An infinite loop does not have an explicit end …

  8. Infinite Loop in Python - Scientech Easy

    Feb 28, 2025 · Learn infinite loop in Python with example, how to create it using while loop statement, how to stop an infinite loop using break statement

  9. Python Looping Techniques - Programiz

    We can create an infinite loop using while statement. If the condition of while loop is always True, we get an infinite loop. num = int(input("Enter an integer: ")) print("The double of",num,"is",2 * …

  10. Python Infinite While Loop - Tutorial Kart

    To write an Infinite While Loop in Python, we have to make sure that the condition always evaluates to true. In this tutorial, we learn some of the ways to write an inifinte while loop in …

  11. Some results have been removed
Refresh