Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (55.6k points)

Can anyone explain the differences between dictionaries and lists in python?

1 Answer

0 votes
by (119k points)

Lists are just like arrays but lists can store multiple datatypes like Integers, strings, as well as objects. Lists are also mutable i.e. we can change even the structure after defining the list. Here is an example of creating the list:

#Create the list with multiple values

List = [‘lists’, ‘are’, cool’]

Dictionary is an unordered collection of data values and is a hashed structure of key and value pairs. Dictionaries holds only one value as an element. Dictionary stores data in key-value pairs and each key-value pair is separated by a colon and each element is separated by a comma.

#creating the dictionary with Integer keys

Dictionary = {1: 'Python', 2: 'is', 3: 'easy'} 

You can check out this Python Tutorial to learn handling lists and dictionaries.

You can watch this video to learn more about the differences between lists and dictionaries.

Browse Categories

...