What is ‘for loop’?

For loop acts as an iterator in python which is an object that enables a programmer to traverse a container.

In short, for loop help us in doing the same type of task for a particular number of times.

Syntax of ‘for loop’

Examples using ‘for loop’

Output

The following example uses list.

Output

Output

Output

Output

Output

The following example uses list as well as tuple.

Output

Comment your doubts in the comment section.

Leave a Reply

Close Menu