code, The above example shows this odd behavior of the for loop because the for loop in Python is not a convention C style for loop, i.e., for (i=0; i>> a = 0 >>> >>> #Increment >>> a +=1 >>> >>> #Decrement >>> a -= 1 >>> >>> #value of a >>> a 0 Python does not provide multiple ways to do the same thing . Lists are mutable, and hence can be modified even after they have been formed. Python - Iterate through list without using the increment variable. ; Three-expression for loops are popular because the expressions specified for the three parts can be nearly anything, so this has quite a bit more flexibility than the simpler numeric range form shown above. Output from this script: ~]# python3 for-loop-2.py 1 squared is 1 2 squared is 4 3 squared is 9 4 squared is 16 5 squared is 25 Example-2: Using for loop with string. Both the while loop and range-of … code. for loop in python: Basically, a for loop is used to iterate elements one by one from sequences like string, list, tuple, etc. I want to process two list items in sequence based on the first item having a given value. The above example shows this odd behavior of the for loop because the for loop in Python is not a convention C style for loop, i.e., for (i=0; i