-> A list is a built-in data structure used to store an ordered collection of items.
-> They are dynamic, resizable and capable of storing multiple data types.
-> Lists are mutable in Python.
-> This means that once a list is created, we can modify it by adding, removing or changing elements without creating a new list.
-> A list is an index-based data structure.
1) Can we have duplicates objects/elements in a list?
Yes, we can.
Eg: grocery_list = ['soap', 12, 'soap', True, 'rice', 'veggies',4.5]
Sample Program:
name = 'muthu'
name = 'M' + name[1:]
print(name)
Output:
Muthu
Example for Mutablity:
grocery_list = ['soap', 12, True, 'rice', 'veggies',4.5]
grocery_list[0] = 'shampoo'
print(grocery_list)
Output:
['shampoo', 12, True, 'rice', 'veggies', 4.5]
List Properties:
1) A list is a group of individual elements in a single entity
2) In a list, Insertion order is maintained.
3) List is Index / Subscript based.
4) Heterogeneous elements are permitted in a list
5) List Elements are Mutable.
Top comments (0)