Well you could directly substract from the value by just referencing the key. Which in my opinion is simpler.
>>> books = {}
>>> books['book'] = 3
>>> books['book'] -= 1
>>> books
{'book': 2}
In your case:
book_shop[ch1] -= 1
More Related Contents:
- How to select random key with common values?
- How do I sort a dictionary by value?
- Split / Explode a column of dictionaries into separate columns with pandas
- List of unique dictionaries
- How to properly subclass dict and override __getitem__ & __setitem__
- How to overcome TypeError: unhashable type: ‘list’
- Writing a dictionary to a csv file with one line for every ‘key: value’
- List of dicts to/from dict of lists
- What do I do when I need a self referential dictionary?
- Splitting a semicolon-separated string to a dictionary, in Python
- Search for a key in a nested Python dictionary
- What is the purpose of collections.ChainMap?
- Accessing items in an collections.OrderedDict by index
- Key-ordered dict in Python
- How do I make a dictionary with multiple keys to one value?
- Get a list of values from a list of dictionaries?
- Creating a new dictionary in Python
- Removing multiple keys from a dictionary safely
- Range as dictionary key in Python
- How to check if a dictionary is empty?
- Why does updating one dictionary object affect other?
- Convert a namedtuple into a dictionary
- How to Create Nested Dictionary in Python with 3 lists
- Pandas DataFrame performance
- How to generate all combination from values in dict of lists in Python
- Has anyone parsed Wiktionary? [closed]
- Python – How to convert only numbers in a mixed list into float?
- merging dictionaries in ansible
- How to convert string representation of dictionary in Pandas DataFrame to a new columns?
- How do I send list of dictionary as Body parameter together with Files in FastAPI?