Member-only story
Built-in Python Data Structure
Data structure in any language provides ability to organize the data so that it can be accesses efficiently as and when required.
In Python we have below data structure.
- List: An ordered, mutable collection created using square brackets
[].
Example:lst = [1, 2, "Gaurav", 38.5, 'v']
List can be created using constructor i.e. list().
Example: lst = list((1, 2, "Gaurav", 38.5, 'v'))
##How to create list in python
lst = [1, 2, "Gaurav", "38.5", 'v']
##Create list in python using list's constructor
lstUsingConstrutor = list((1, 2, "Gaurav", 38.5, 'v'))
##How to create empty list in python
emptyLst = []List element can be accessed by index. Starting index is 0 and last element index is (number of element in list-1).
2. Tuple: Similar to a list but immutable, created using parentheses ().
Example: tpl = ("Gaurav", "Verma", "Python")Tuple can be created using constructor i.e. tuple().
Example: tpl= tuple(("Gaurav", "Verma", "Python"))









