as demonstrated by this small programthe result is not what we want we added the value of two to every elementbut after the loop finishedour list was unchanged the reason for this behavior is that although the list is traversed as desired when we create the for loop using for in :the variable is an ordinary (intvariableand it is in fact copy of each element in the listand not the actual element thereforewhen we change ewe change only the copy and not the actual list element the copy is overwritten in the next pass of the loop anywaysoin this caseall the numbers that are incremented by two are simply lost the solution is to access the actual elements by indexing into the listv [- for in range(len( )) [iv[ print( [ notice in particular the use of range(len( ))which is common construction in python programs it creates set of integers running from zero to len( )- that can be iterated over with the for loop and used to loop through all the elements in the list list comprehensions for compact creation of lists abovewe introduced one common way of constructing listswhich is to start with an empty list and use for loop to fill it with values we can extend this example to fill several lists in one loopfor instanceif we want to examine the effect of low and high interest rates on our bank deposit we start with two empty lists and fill both with values in the same loopp r_low r_high a_high [a_low [for in range( + )a_low append( *( +r_low/ )**na_high append( *( +r_high/ )**nthis approach to using for loop to fill list with values is so common in python that compact construct has been introducedcalled list comprehension the code in the previous example can be replaced by the followingp r_low r_high a_low [ *( +r_low/ )** for in range( + )a_high [ *( +r_high/ )** for in range( + )