![]() |
python list |
Python | List
- list are used for to store multiple data in single variable
- list are created using square [ ] brackets.
- The list is one of 4 built in datatype available in Python used to store collection of data ,the other 3 are Tuple ,Set and Dictionary
Example
[ 'mango' ,' banana', 'apple' ]
[ 1,2, 3 ]
[ 1,2, 3 ,' banana', 'apple' ]
print List
The list are create by placing data in square brackets [ ] , separated by commas
print() method is used for print a list
Example
list = [ 'mango' ,' banana', 'apple' ]
print(list)
Output
[ 'mango' ,' banana', 'apple' ]
in list we can contains different types of data like float ,integer ,string etc
Example
list = [ 'mango' ,1, 5.8 ]
print(list)
Output
[ 'mango' ,1, 5.8]
Nested List
A list contain inside another list that is called nested list
Example
list = [ 'mango' ,' banana', [ 2 ,1, 5.8 ]]
print(list)
Output
[ 'mango' ,' banana', [ 2 ,1, 5.8 ]]