In Python For loop, the statement is executed sequentially until the condition satisfied. The first statement in a function is executed first, followed by the second, and so on. Using Loops we can execute a block of code several times.
Python has two types of loops
- while loops
- for loops
For loop sequence
# List Sequence Example fruits = ["apple", "banana", "cherry"] for x in fruits: print(x) # String Sequence Example for x in "StudyGyaan": print(x)
Range ( ) function in Python
range() function is python in-build function, returns a sequence of numbers, starting from 0 by default, and increments by 1 (by default), and ends at a specified number.
for x in range(6): print(x)
Whats Next – Python Loop Control Statements