About 4,860,000 results
Open links in new tab
  1. python - "for loop" with two variables? - Stack Overflow

    Sep 6, 2013 · There's two possible questions here: how can you iterate over those variables simultaneously, or how can you loop over their combination. Fortunately, there's simple …

  2. Changing iteration variable inside for loop in Python

    I am trying to do something as simple as changing the varible in which I am iterating over (i) but I am getting different behaviours in both Python and C. In Python, for i in range(10): print i, if i …

  3. Python For Loops - W3Schools

    Python For Loops. A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string). This is less like the for keyword in other programming languages, …

  4. Using multiple variables in a for loop in Python

    Aug 20, 2018 · Actually, "the simplest way of using a for loop an iterating over an array" (the Python type is named "list" BTW) is the second one, ie for item in somelist: …

  5. For Loop with Two Variables in Python - AskPython

    Feb 13, 2023 · You can quickly write and execute the code in Python faster than in other languages. Here we will learn about the for loop and how to loop through with the two …

  6. Python for Loops: The Pythonic Way – Real Python

    Python’s for loop allows you to iterate over the items in a collection, such as lists, tuples, strings, and dictionaries. The for loop syntax declares a loop variable that takes each item from the …

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

  8. Python For Loops - GeeksforGeeks

    Dec 10, 2024 · For loop can iterate over any iterable object, such as dictionary, list or any custom iterators. For Loop Example: Note: In Python, for loops only implement the collection-based …

  9. How to Use a for Loop for Multiple Variables in Python

    Feb 9, 2025 · iterable: This is the iterable (list, tuple, string, etc.) for which you want to generate an enumerate object. It can be any iterable object where you want to access both the …

  10. Python For Loop: Syntax, Examples & Use Cases

    Learn Python for loop from scratch! This comprehensive guide covers syntax, iterating sequences, range(), enumerate(), break/continue, real-world examples & more.

  11. Some results have been removed
Refresh