Thursday, February 8, 2018

FOR loop in python

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

No comments:

Post a Comment

Hadoop - What is a Job in Hadoop ?

In the field of computer science , a job just means a piece of program and the same rule applies to the Hadoop ecosystem as wel...