Page 129 - Trackpad_V1_Book 8_Flipbook
P. 129

1.   What is a string?
                                              ______________________________________________________
                         uiz   Bee        2.  What are escape sequences?

                                              ______________________________________________________





                          LIST


                 In Python, a list is a type of container that is used to store a list of values of any type. One can
                 store an integer, string as well as objects in a single list. Each element in a list is assigned an index
                 number. The first index is 0, the second index is 1, the third is 2, and so on.


                 CREATING A LIST

                 Lists can be created by inserting the elements in square brackets []. The elements in the list are
                 separated by a comma.

                 Program 11: To create a list









                 You will get the following output:















                 Let us study about some of the ways through which we can create different types of lists.


                 Empty List

                 An empty list in Python is created using [ ]. There are two ways to create an empty list.

                 Program 12: To create an empty list














                                                                                   Functions, String and List in Python  127
   124   125   126   127   128   129   130   131   132   133   134