For Loop in Python

For loop in python may be used to iterate the elements of List, Tuple or Set as following

myList=[1,2,3] # Similarly this loop can iterate the elements of Tuple or Set.
for i in myList:
print(i)

    Output:
    1
    2
    3

For loop can also be iterated with the help of range as following.

 

for i in range(5):
print(i)

    Output:
    0
    1
    2
    3
    4

Factorial Program in Python using for loop

n=int(input("Enter the number to find factorial"))
fact=1
for i in range(1,n+1):
fact=fact*i
print("The factorial of",n,"is",fact)
Click Here

Video/ C Introduction

Watch video in full size