for loop in Python

for loop is a definite loop and works with all types of values like integer, float, string, list in python.
for in :

Example: for loop with number values
Example 1:
# For Loop – Prints the number from 1 to 10
for num in range(1,11):
range() function is used to specify the range of values for integer and float datatype.

Example 2:
# For Loop – Prints the number from 1 to 10 in reverse order
for num in reversed (range(1,11,2)):

Example 3:
# For loop with String value
strN=”Win Corporate”

for ch in strN:
print (“Current Letter :” + ch)
#prints one character at a time from starting to the end of the string

Example: 4
# For loop with List
Company = [‘Win’, ‘Corporate’, ‘Training’]
for c in Company:
print (“Current value :” + c)
# prints one item at a time from the list.

Happy Learning
Win Corporate Training
View My Profile