Programming with Python

  1. Home
  2. Docs
  3. Programming with Python
  4. Looping in python
  5. For loop in python

For loop in python

For loop is a python loop which repeats a group of statement a specified number of times. The for loop of python is designed to process the items of any sequence, such as a list or a string, one by one.

The for loop provides a syntax where the following information is provided:-

  • Boolean condition
  • The initial value of the counting variable
  • Increment of counting variable.

syntax:-

for variable in sequence:
    statements

e.g.,

n = 10
for i in range(0, n):
	print(i)
Output- 
0
1
2
3
4
5
6
7
8
9

Was this article helpful to you? Yes No

How can we help?