I am getting this TypeError in this simple code, appending a value to a dictionary.
dict = {}
dict['key' : 'value']
print(dict)
dict = {}
dict['key' : 'value']
print(dict)
dict = {}
dict['key'] = 'value'
print(dict)
[index1 :index2 ]
is list slice operation, which will not work on dict
well you can do much more d={} for appending to it you can do
d={'key1':'value1','key2':'value'}
also
d.update(key3:'val3')
hope this helps
You can't add like this, it's a dictionary that takes key and value as a separate entity like
dict['key'] = 'value'
After doing this, the dictionary will automatically convert itself like-
dict['key' : 'value']