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
# 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.
# For Loop – Prints the number from 1 to 10 in reverse order
for num in reversed (range(1,11,2)):
# For loop with String value
for ch in strN:
print (“Current Letter :” + ch)
#prints one character at a time from starting to the end of the string
# 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.
Win Corporate Training