About 273,000 results
Open links in new tab
  1. how to use iterator in while loop statement in python

    Nov 28, 2019 · i = iter(range(10)) while next(i): # your code The point of this would be to build iteration into the while loop statement, making it similar to a for loop, with the difference being …

  2. Loop Through a List using While Loop in Python - GeeksforGeeks

    Feb 7, 2024 · In Python, for and while loops are used to iterate over a sequence of elements or to execute a block of code repeatedly. When it comes to user input, these loops can be used to …

  3. Python While Loops - W3Schools

    Python has two primitive loop commands: With the while loop we can execute a set of statements as long as a condition is true. Note: remember to increment i, or else the loop will continue …

  4. Python While Loop - GeeksforGeeks

    Dec 10, 2024 · Python While Loop is used to execute a block of statements repeatedly until a given condition is satisfied. When the condition becomes false, the line immediately after the …

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

    Mar 8, 2025 · We can use for loop to iterate lists, tuples, strings and dictionaries in Python. We can also use the index of elements in the sequence to iterate. The key idea is to first calculate …

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

    Aug 18, 2023 · This article explains a while loop in Python. Unlike a for loop, which sequentially processes iterable elements such as a list, a while loop repeats as long as its condition …

  7. Python "while" Loops (Indefinite Iteration)

    Python "while" Loops (Indefinite Iteration) A while loop repeats code until the condition is met. Unlike for loops, the number of iterations in it may be unknown. A while loop always consists …

  8. Mastering List Iteration in Python: A Comprehensive Guide for ...

    1 day ago · The while loop is useful when you need to access the elements by their index, such as when you need to modify the list in place during the iteration. 3. Using the enumerate() …

  9. How to Iterate Through a List Using While Loop in Python

    In Python, we can iterate through a list using a while loop by maintaining an index variable that helps access each element one by one until we reach the end of the list.

  10. Loops and Iteration - Python

    1 day ago · You want clean, readable iteration; 2. While Loops. Purpose: Repeats a block of code as long as a condition is True. Syntax: while condition: # code block. Example 1: Basic while …

Refresh