22 августа 2023
Aa.X= {}
Is it a set or a dict
It is a dictionary, if you want to declare an empty set you do it in the following way: x = set()
Aa.But it shows same curly bracket for sets here
it's right:
empty list: x = []
empty set: x = set()
empty tuple: x = ()
empty dictionary: x = {}
With data it will look like this:
x = [1, 2, 3, 4]
x = {1, 2, 3, 4}
x = (1, 2, 3, 4)
x = {'one': 1,'two':2, 'three': 3, 'four': 4}
Aa.Thanks a lot.
What's the use of empty lists, sets, tuples, dicts really?
They are often used as containers to store data that will be added later during program execution. For example, you can create an empty list and then add items as the data is processed. Empty sets can be used to store unique items, empty tuples can be used as placeholders, and empty dictionaries can be used to store key-value pairs.