nested lists and list slicing as described abovelists in python are quite general and can store any objectincluding another list the resulting list of lists is often referred to as nested list instead of storing the amounts resulting from the low and high interest rates above as two separate listswe could put them together in new lista_low [ *( +)** for in range( )a_high [ *( +)** for in range( )amounts [a_lowa_highlist of two lists print(amounts[ ]the a_low list print(amounts[ ]the a_high list print(amounts[ ][ ]the rd element in a_high the indexing of nested lists illustrated here is quite logicalbut can take some time getting used to the important thing is thatif amounts is list containing liststhenfor instanceamounts[ is also list and can be indexed in the way we are used to indexing into this list is done in the usual waysuch thatfor instanceamounts[ ][ is the first element of the first list contained in amounts playing bit with indexing nested lists in the interactive python shell is useful exercise to understand how they are used iterating over nested lists also works as expected considerfor instancethe following code for sublist in somelistfor sublist in sublist for value in sublist work with value heresomelist is three-dimensional nested listthat isits elements are listswhichin turncontain lists the resulting nested for loop looks bit complicatedbut it follows exactly the same logic as the simpler for loops used above when the outer loop startsthe first element from somelist is copied into the variable sublist and then we then enter the code block inside the loopwhich is new for loop that will start traversing sublist that isfirst copying the first element into the variable sublist then the process is repeatedwith the innermost loop traversing all the elements of sublist copying each element into the variable valueand doing some calculations with this variable when it reaches the end of sublist the innermost for loop is overwe "move outwardone level in terms of the loopsto the loop for sublist in sublistwhich moves to the next element and starts new run through the innermost loop similar iterations over nested loops can be obtained by looping over the list indicesas followsfor in range(len(somelist))for in range(len(somelist[ ]))