What's the difference between a list and a dictionary? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What's the difference between a list and a dictionary?

2nd Aug 2016, 9:23 PM
LaraAckermann
LaraAckermann - avatar
3 Answers
+ 4
list is a collection of data(elements ) where as dictionary is collection of key,value pair. for ex: list = [1, 2,3,4,5] dict = {'name': 'Pradeep' ,'age': 27}
3rd Aug 2016, 11:02 AM
Pradeep Bilaiya
Pradeep Bilaiya - avatar
+ 3
Basic difference is index ,to recall any value from list we use index (list[index]) this index is predefined integer numbers and start from 0 to onwards while in dictionary instead of index there is a key. key is programmer defined unique (any data type like string,int,float) value and in dictionary we use key to recall data
8th Aug 2016, 2:22 AM
Abdullah Mukhtar
Abdullah Mukhtar - avatar
+ 1
list can be sorted or reversed. Dict cannot.
26th Nov 2016, 7:04 AM
Fadi Elrami