Header Ads

Responsive Ads Here

For Loop in Python

 For Loop in Python



#Prints counting from 0 - 9
for i in range(10):
    print(i)



   
#Will print odd numbers from 1 - 10
for i in  range(1, 11, 2):
    print(i)



   
#Will print even numbers from 1 - 10
for i in  range(2, 11, 2):
    print(i)
   



#Will loop on the string  
name = "Xtra"
for i in name:
    print(i)

Powered by Blogger.