Python Loop statements are used to execute a block of code repeatedly over and over based on a condition or execute a block of code repeatedly for each element in a collection.
In this tutorial, we list out the looping statements, and looping control statements available in Python.
There are two looping statements in Python. The following tutorials explain each of these looping statements in detail.
- Python While LoopPython Tutorial to learn the syntax and usage of While Loop statement.
- Python For LoopPython Tutorial to learn the syntax and usage of For Loop statement.
The following tutorials cover different scenarios involving While Loop.
- Python While Loop with Multiple ConditionsPython Tutorial to write While Loop statement with its boolean expression containing multiple conditions (a compound condition).
- Python While Loop with BreakPython Tutorial to write While Loop with a break statement inside it.
- Python While Loop with ContinuePython Tutorial to write While Loop with a continue statement inside it.
- Python Nested While LoopPython Tutorial to write a While Loop inside a While Loop which is called Nesting.
- Python Infinite While LoopPython Tutorial to write a While Loop where the condition is always true, and the While Loop is executed indefinitely.
- Python Pattern Programs using While LoopPython Tutorial to write programs that print patterns to console, using While Loop.
The following tutorials cover different scenarios involving For Loop.
- Python For Loop – RangePython Tutorial to write For Loop with a Range object.
- Python For Loop – Access IndexPython Tutorial to access index of the elements from the iterator, in a For Loop.
- Python For Loop – Increment in StepsPython Tutorial to write a For Loop that accesses the elements from the iterator in steps, leaving out the elements in-between the steps.
In this Python Tutorial, we learned different types of loops in Python, and also different scenarios where these looping statements can be used.