About 3,130,000 results
Open links in new tab
  1. Loops in Python – For, While and Nested Loops - GeeksforGeeks

    Mar 8, 2025 · Loops in Python are used to repeat actions efficiently. The main types are For loops (counting through items) and While loops (based on conditions). Additionally, Nested Loops …

  2. Python - loop inside ternary operator - Stack Overflow

    Jul 15, 2016 · I am learning python, and trying to use some ternary operators. I am trying to make the function below using a ternary: count = 0. for i in nums: if i == 9: count += 1. return count. 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. Python for Loops: The Pythonic Way – Real Python

    Python’s for loop iterates over items in a data collection, allowing you to execute code for each item. To iterate from 0 to 10, you use the for index in range(11): construct. To repeat code a …

  5. For-LoopsPython Numerical Methods - University of …

    We present several more examples to give you a sense of how for-loops work. Other examples of sequences that we can iterate over include the elements of a tuple, the characters in a string, …

  6. Python Operators - Python Guides

    Learn more about the topic Python Conditional Statements and Loops. Practical Examples of Python Operators ... Check out all the tutorials related to the topic Python Arrays. Best …

  7. Python Loops: A Comprehensive Guide for Beginners

    Sep 18, 2023 · In Python, there are two different types of loops: the for loop, and the while loop. Each loop has its own way of executing and exiting, and knowing when to use the correct loop …

  8. Python Array Operations: Loop Through Array With Examples

    May 17, 2024 · When it comes to looping through arrays in Python, one of the most common methods is using a for loop. This type of loop allows you to iterate over each element in the …

  9. Python For Loops - GeeksforGeeks

    Dec 10, 2024 · Python For Loops are used for iterating over a sequence like lists, tuples, strings, and ranges. For loop allows you to apply the same operation to every item within loop. Using …

  10. Python Loop Through an Array - W3Schools

    Looping Array Elements. You can use the for in loop to loop through all the elements of an array.