DemandMatrix Interview Question

Difference between sets and list in python

Interview Answer

Anonymous

Jun 25, 2020

List: 1. Order of element is well defined. 2. Duplicates are possible. 3. Any object can be participate. 4. Longer lists are slower Sets: 1. Order of element is unknown 2. Elements are unique. 3. Only hashable objects can be inserted (tuples, numbers but not list). 4. Length does not affect performance.

1