Lists : Python lists are containers used to store a list of values of any data type. In simple words, we can say that a list is a collection of any data type items or elements. E.g. Copy list1 = [ 'harry' , 'ram' , 'Aakash' , 'shyam' , 5 , 4.85 ] The above list contains strings, integer, and even float type data. A list can contain any kind of data i.e. it’s not mandatory to form a list of only one data type. The list can contain any kind of data in it. Remember we saw indexing in strings? List elements can also be accessed by using Indexes i.e. first element of the list has 0 indexes and the second element has 1 as its index and so on. Note: I f you put an index which isn’t in the list i.e. that index is not there in list then you will get an error. i.e. if a list named list1 contains 4 elements, list1[4] will throw an error because the list index starts from 0. Have a look at the examples below: List Methods : Here is the list of list methods of ...
Comments
Post a Comment