The for loop iterate over the items of any sequence like list or a string.
Syntax:
for iter_var in sequence:
statement(s)
Example :
a = [2,3,4,5,6]
for i in a:
print(i)
#output :
2
3
4
5
6
For Loop with range :.
Example :
for i in list(range(5)):
print(i)
#output :-
0
1
2
3
4
Syntax:
for iter_var in sequence:
statement(s)
Example :
a = [2,3,4,5,6]
for i in a:
print(i)
#output :
2
3
4
5
6
For Loop with range :.
Example :
for i in list(range(5)):
print(i)
#output :-
0
1
2
3
4
No comments:
Post a Comment