Python for Loop

The for loop is useful to iterate over the elements of a sequence. It means, the for loop can be used to execute a group of statements repeatedly depending upon the number of elements in the sequence.

The for loop can work with sequence like string, list, tuple, range etc.

The syntax or format of for loop is:

for var in sequence:
statements


The first element of the sequence is assigned to the variable written after 'for' and then the statements are executed.

Next, the second element of the sequence is assigned to the variable and then the statements are executed second time. In this way, for each element of the sequence, the statements are executed once

So, the for loop is executed as many times as there are number of elements in the sequence.

Write a Python program to display characters of a string using for loop.


A Python program to display odd numbers from 1 to 10 using range() object.

A Python program to display each character from a string using sequence index.


Write a program to display numbers from 10 to 1 in descending order.


Write a program to display the elements of a list using for loop.


Write a Python program to display and find the sum of a list of numbers using for loop.