+ 1
How to define a dictionary size?
Like we define in list
3 Answers
+ 6
Zahed Shaikh
I don't think you need to define a size of dictionary or list.
We initialise dictionary or list like this:
dictionary = {}
list1 = []
So there is no need to define size. You can add elements as many you want but If you want restrict user to add defined size of data you can just validate it after getting size of dictionary or list.
+ 2
Zahed Shaikh
"You mean how to get size"?
Same as list :
dictionary = {1 : 2, 3 : 4}
print(len(dictionary))
0
Can we set a predefined dictionary size