Adding a element in dictionary which consist of dictionaries.

You need to use subscription, so object[...], to address elements in the dictionary:

inventory['bag'].append('test')

Here inventory['bag'] retrieves the value associated with the 'bag' key. This is a list object, so you can then call the append() method on that result.

Leave a Comment