Computer Science, asked by rongamer282005, 1 day ago

write two difference between list and dictionary with one example of each​

Answers

Answered by thesiddhartha
2

Answer:

              List                                    Dictionary

1. Lists are mutable in nature     1. Dictionaries are mutable, but

                                                       keys  do not allow duplicates

2. Collection of various              2. Collection of elements in the      elements just like an array             hashed structure as key-value           in C++.                                               pairs.

For Example:                               For Example:

slist = ["Python", "is", "Fun"]       sdict = { "vegetable": "potato",

print(slist)                                                   "fruit": "banana",

                                                                    "chocolate": "gems"}

                                                       print(sdict)

Output                                         Output

['Python', 'is', 'Fun']                       {'vegetable': 'potato', 'fruit':                          

                                                        'banana', 'chocolate': 'gems'}

Similar questions