Page 129 - Plus V4 with Adobe class 8
P. 129

On running the above program, you will get the following output:


















                             Factbot

                     If  a user tries to access a list element by  using  floating-point  indexing,  it will  result in
                     IndexError.


            Negative Indexing

            Negative indexing means the index of -1 refers to the last elements of the list, the index of -2 refers to
            the second last element.

            To traverse a list by using negative indexing, follow the program as given below.













            On running the above program, you will get the following output:
















            Traversing Nested Lists

            Nested list can be traversed by using the index operator.

            To create two nested lists, follow the program as given below.












                                                                                                #List in Python 127
   124   125   126   127   128   129   130   131   132   133   134