[Solved] Why python showing can’t assign to literal in dictionary? [closed]


The first = in the second line is wrong. This should work:

dict1['W'] = ['Spring']

Note however that this way, you are setting dict1['W'] to a list containing 'Spring', not to the string “Spring” itself.

solved Why python showing can’t assign to literal in dictionary? [closed]