What is the difference between List and Dictionary data types in Python?

Main differences between List and Dictionary data types in Python are as follows:

I. Syntax: In a List we store objects in a sequence. In a Dictionary we store objects in key-value pairs.

II. Reference: In List we access objects by index number. It starts from 0 index. In a Dictionary we access objects by key specified at the time of Dictionary creation.

III. Ordering: In a List objects are stored in an ordered sequence. In a Dictionary objects are not stored in an ordered sequence.

IV. Hashing: In a Dictionary, keys have to be hashable. In a List there is no need for hashing.


Posted

in

Tags:

Comments

Leave a Reply