WHAT IS THE DIFFERENCE BETWEEN [ ] AND { ] IN PYTHON?

KABIRU SHUAIBU

INSIGHTFUL DATA ANALYST WITH OVER THREE YEARS OF EXPERIENCE WHO IS PROCESS-ORIENTED. WITH EXTENSIVE EXPERIENCE EVALUATING AND ANALYZING DATA TO GENERATE DEVELOPMENT FOR TECHNOLOGICAL AND FINANCIAL FIRMS. PROVIDE THE INSIGHTS, ANALYTICS, AND BUSINESS INTELLIGENCE REQUIRED TO MAKE DECISIONS.

7 articles

December 14, 2022

In Python, square brackets [] are used for lists, while curly braces {} are used for dictionaries.

A list is a collection of items that are ordered and changeable. You can access items from a list by their index, and you can add or remove items from a list. Here is an example of a list in Python:

my_list = ['apple', 'banana', 'orange'] 
 

A dictionary is a collection of items that are unordered and changeable. Each item in a dictionary consists of a key and a value, and you can access items from a dictionary by their keys. Here is an example of a dictionary in Python:

my_dict = { 
 'name': 'John Doe', 
 'age': 32, 
 'city': 'New York' 

 

Both lists and dictionaries are data types that are commonly used in Python, but they are used for different purposes. Lists are used to store a collection of items that are ordered and accessible by their index, while dictionaries are used to store a collection of items that are unordered and accessible by their keys.

Report this

Published by

KABIRU SHUAIBU

INSIGHTFUL DATA ANALYST WITH OVER THREE YEARS OF EXPERIENCE WHO IS PROCESS-ORIENTED. WITH EXTENSIVE EXPERIENCE EVALUATING AND ANALYZING DATA TO GENERATE DEVELOPMENT FOR TECHNOLOGICAL AND FINANCIAL FIRMS. PROVIDE THE INSIGHTS, ANALYTICS, AND BUSINESS INTELLIGENCE REQUIRED TO MAKE DECISIONS.

7 articles

December 14, 2022


Like

Reactions