Page 73 - Modular v1.1 Pyhton
P. 73

Clickipedia



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

                 Traversing Nested Lists

                 Nested list can be traversed by using the index operator.
                 Program 3: To create two nested lists.










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















                 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.
                 Program 4: Traversing a list by using negative indexing.












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





















                                                                                                 List in Python   71
   68   69   70   71   72   73   74   75   76   77   78