I ran the following code in Jupyter Notebook:
list_1 = []
list_1 += "cat"
print(list_1)
and got the following output:
['c', 'a', 't']
but when i ran this:
list_1 = []
list_1 = list_1 + "cat"
print(list_1)
it gave the following error:
TypeError: can only concatenate list (not "str") to list
I failed to understand this as in both the methods, a string is being added to a list.
Is it something about the '+=' notation or something related to the concatenation of lists and strings that's causing the bug?