There are four collection data types in the Python programming language :
Like a string, a list is a sequence of values. In a string, the values are characters; in a list, they can be any type. The values in a list are called elements or sometimes items. There are several ways to create a new list; the simplest is to enclose the elements in square brackets ( [ and ] ): 1. [10,20,30,40]
2. ["your name","your age","address"]
The first example is a list of four integers. The second is a list of three strings. The elements of a list don’t have to be the same type. python also have nested list feature (A list within another list is nested) : ["ayan",1,["age",24]]
Creating a list is as simple as putting different comma-separated values between square brackets. To access values in lists, use the square brackets for slicing along with the index or indices to obtain value available at that index.
|
You can loop through the list items by using a for loop:
|
To determine if a specified item is present in a list use the in keyword:
|
python list have built-in methods, methods help us to manipulate list items.
|
Python includes many built-in methods but here we just adding some of the following built-in methods to manipulate lists :
We Are Currently Working On Our Android Application Development and We already have two YouTube channels their name is CodeX or NightHawk. CodeX is for programming related videos and NightHawk is for online game streaming so please supporting us and Subscribe to our channels, Thank you