For
Loop: It is used to iterate a variable over a
sequence (i.e., list or string) in the order that they appear.
Syntax: for <variable> in <sequence>:
#statements
Program:
for i in range(1,11):
print(i)
Output:
1
2
3
4
5
6
7
8
9
10
Program-1:
for
i in range(10,0,-1):
print(i)
Output:
10
9
8
7
6
5
4
3
2
1
Comments
Post a Comment