Difference between list and dict?



Vikas Said

+0 -0

List and Dictionary both are build-in data types of in Python there are different feature.
List
List are mutable data type that contains heterogeneous element written inside[],List indexing start with 0.
Dictionary
Dictionary is collection of unordered key or data and values means every value of dictionary contains key and values key are immutable(we cannot change) and value are mutable and dictionary cannot have same keys. It is written like {key1:value1,key2:value2}.



Ayush Said

+0 -0

Lists maintain order and allow duplicate elements, accessed by index, while dictionaries store key-value pairs with unique keys for fast retrieval, accessed by keys, offering efficient data organization and access methods differing fundamentally.



Aditya Said

+0 -0

Lists: Ordered sequences of items accessed by their position (index). They can hold duplicates and elements can be changed.
Dictionaries: Unordered collections of key-value pairs. Each key must be unique and is used to access its corresponding value.
Mutability: Both lists and dictionaries are mutable, allowing their contents to be modified after creation.



Submit Your Response