How to add list in Python

What is list in python,learn it easy way

The list  in python is simplest type of collection in python.List are the basic example of the collection of the collection of the heterogeneous( different data types).It stores the  data in the square brackets  separated  with  the comma's. 


How to declare and  initialise the list

The declaration and initialisation of the list in python is so easy to do for that just you have  to just follow the syntax:
list_name =["list_item1","list_item2".......]
And we can just use print statement to print the result

Rules to declare the list

What's are the rules to declare and initialise an list in python are so simple:

1.Always declare it inside the square brackets.

2.Use double quotes to add string data types.

3.Always remeber to use comma to separate the items in the list.

4.Remeber list is just like array,like array it also have indexing


Accessing list items by position

Like in array,list is also  accessed through the index of the  item in the list.The first index is the zero and the index increases with the number of items.
Syntax









List methods

1. append(): 

Adds an element to the end of the list.

2. `extend()`:

 Adds elements from another list to the end of the list.

3. `insert()`:

 Inserts an element at a specified position in the list.

4. `remove()`: 

Removes the first occurrence of a specified value from the list.

5. `pop()`:

 Removes and returns the element at a specified position in the list.

6. `index()`:

 Returns the index of the first occurrence of a specified value.

7. `count()`: 

Returns the number of occurrences of a specified value in the list.

8. `sort()`:

Sorts the elements of the list in ascending order.

9. `reverse()`:

 Reverses the order of the elements in the list.

10. `clear()`:

 Removes all elements from the list.

These methods offer a variety of ways to manipulate and work with lists in Python.