About 35,100,000 results
Open links in new tab
  1. Python - Loop Lists - W3Schools

    Use the range() and len() functions to create a suitable iterable. Print all items by referring to their index number: The iterable created in the example above is [0, 1, 2]. You can loop through the …

  2. Iterate over a list in Python - GeeksforGeeks

    Jan 2, 2025 · Python provides several ways to iterate over list. The simplest and the most common way to iterate over a list is to use a for loop. This method allows us to access each …

  3. python - How does this "x for x in..." construct work ... - Stack Overflow

    Here are a few more examples which should clarify the difference between the first and second x in your question: This simply gives a list of 10 ones, the same as [1] * 10. This gives x squared …

  4. 7 Ways to Loop Through a List in Python - LearnPython.com

    Jul 29, 2022 · Using a Python for loop is one of the simplest methods for iterating over a list or any other sequence (e.g. tuples, sets, or dictionaries). Python for loops are a powerful tool, so …

  5. How to Use a For Loop to Iterate over a List - Python Tutorial

    To iterate over a list, you use the for loop statement as follows: # process the item Code language: Python (python) In this syntax, the for loop statement assigns an individual element …

  6. Python List For Loop

    In this tutorial, we will learn how to use For loop to traverse through the elements of a given list. In general, the syntax to iterate over a list using for loop is. statement(s) where. element contains …

  7. How to Use Lists in Python – Explained with Example Code

    Mar 1, 2024 · In Python, lists are a cornerstones of data organization and manipulation – so I think they deserve a thorough exploration. This article delves into how to create and manipulate lists …

  8. Python: 6 Ways to Iterate Through a List (with Examples)

    Jun 6, 2023 · Use the range() function to generate indices corresponding to the list length (returned by the len() function). Use a for loop to iterate over the range of indices. Access each …

  9. How to Iterate Through a List in Python? - Python Guides

    Sep 20, 2024 · To iterate through a list in Python, the most straightforward method is using a for loop. The syntax is simple: for item in list_name:, where item represents each element in the …

  10. 13 Ways to Loop Through a List in Python [Examples Included]

    Jun 21, 2021 · Learn how to loop through a list in Python in record time with our short, step-by-step guide! Learning how to loop through a list in Python is a basic yet incredibly powerful …

Refresh