Call us at 0700-922-6559 or Click here

What are lists in Python?

Python lists are containers to store a set of values of any data type.

Example-

The python lists can contain different types of elements such as integer, float, string, boolean, etc.

The above list is a collection of different types of elements that we can use in lists.

Indexing of lists

Indexing of lists is incredibly easy to understand. If a programmer wants to work on the first element of the list then it will count as a zero(0) index. Let’s understand this by taking an example.

 (This is known as List Slicing)

List Methods: 

1.sort( )=updates the list in our desirable elements.Like 

2.reverse()=updates the list in a reverse mode.

3. append()=add programmer’s particular element at the end of the list.

4. insert( )=This will add the programmer’s particular choice of element at the index which is chosen by him/her. Like 

5. pop(3)=It will delete an element at index 3 and return its value. Like

6. remove(5)=It will remove 5 from the list.

Leave a Reply

Your email address will not be published. Required fields are marked *