In the for loop I have a dictionary object like this:
mob1 = {
"Item": item1,
'Price': price1,
'Desc': desc1
}
and I tried to append it like:
list.append(mob1)
I get the following error:
Traceback (most recent call last):
File "/home/turbolab/Documents/python_test/Sep 23 data_to_json test.json", line 32, in <module>
list.append(mob1)
TypeError: descriptor 'append' requires a 'list' object but received a 'dict'
list
is a class. append
is a method of that class which has to be called on instances of list
.
list.append(7) # error
mylist = list()
mylist.append(7) # ok
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With