Well you could directly substract from the value by just referencing the key. Which in my opinion is simpler.

Copy>>> books = {}
>>> books['book'] = 3       
>>> books['book'] -= 1   
>>> books   
{'book': 2}   

In your case:

Copybook_shop[ch1] -= 1
Answer from Christian W. on Stack Overflow
🌐
W3Schools
w3schools.com › python › python_dictionaries_change.asp
Python - Change Dictionary Items
MongoDB Get Started MongoDB Create DB MongoDB Collection MongoDB Insert MongoDB Find MongoDB Query MongoDB Sort MongoDB Delete MongoDB Drop Collection MongoDB Update MongoDB Limit ... Python Overview Python Built-in Functions Python String Methods Python List Methods Python Dictionary Methods Python Tuple Methods Python Set Methods Python File Methods Python Keywords Python Exceptions Python Glossary
Discussions

Update values in a dictionary, from a list, if the value is currently 1
my_dict = {'date1':0, 'date2':1, 'date3':0, 'date4':1} my_list = [80, 20] list_index = 0 new_dict = {} for key in my_dict: value = my_dict[key] if value == 1: new_dict[key] = my_list[list_index] list_index += 1 else: new_dict[key] = my_dict[key] print(new_dict) More on reddit.com
🌐 r/learnpython
5
0
October 28, 2022
Need to modify a value in a dictionary to a float and append dictionary
Hello everyone. I have a value in a dictionary that I need to divide by a float and then append the dictionary to update the value. When I try to do this python says it can’t do this as the number is not a float. Here is what I have so far: car = {‘price’: ‘30000’} More on discuss.python.org
🌐 discuss.python.org
7
0
September 7, 2022
Update Dictionary Value if Key exists
So I have this Dictionary 3.00 And I come across another apple row, I’m checking to see if that key exists, if it ... More on forum.uipath.com
🌐 forum.uipath.com
9
0
February 25, 2019
How to change a dicts value for one of the keys?
list = {} Triggered. Sorry, mostly kidding, but list is a type, and definitely should not be used as the variable name for a dict. Also, using a try/except on EOFError for breaking out of your while loop is really weird. Are you trying to mess with people? =) Again, kidding, lol. I basically want to get the value of one key in my dict and add to it, but not to any of the other keys. I have searched all over the internet and can not find or just do not know how to word it to find a solution. What are you actually expecting to do? As written, your code doesn't attempt to change any value, and doing so is very simple. Let's say one of your inputs is "apple". This creates the following key/value pair in your dict: {"apple": 1}. To change this value to, say, 5, you'd simply do this: my_dict["apple"] = 5 That changes the value from 1 to 5. Now, if you want to add to it in the sense of a number, you can do this instead: my_dict["apple"] += 5 This will add 5 to the original value of 1, so your new dict will be this: {"apple": 1} Finally, if you mean "add" as in "add additional values", you need to convert your value into a type that allows for multiple values. The most common is to use a list like this: my_dict = {} dict_key = input() my_dict[dict_key] = [1] my_dict[dict_key].append(5) print(my_dict) # input: test # output: {'test': [1, 5]} If you gave some more details about what you are trying to do we can probably help more. Does that make sense? More on reddit.com
🌐 r/learnpython
23
4
May 13, 2024
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-dictionary-update-method
Python Dictionary update() method - GeeksforGeeks
February 16, 2026 - Explanation: update({'a': 50}) replaces old value of 'a'. Example 3: In this example, keyword arguments are used instead of another dictionary.
🌐
Reddit
reddit.com › r/learnpython › update values in a dictionary, from a list, if the value is currently 1
r/learnpython on Reddit: Update values in a dictionary, from a list, if the value is currently 1
October 28, 2022 -

Say I have code like so:

my_dict = {date1:0, date2:1, date3:0, date4:1} my_list = [80, 20]

Is there a way to get output as follows:

new_dict = {date1:0, date2:80, date3:0 date4:20}

I've tried so much at this point but just cannot get it working, is my initial structure the issue? i.e. you're not supposed to use dictionaries like this? Either you can't do this, or there's a fundamental gap in my knowledge preventing me connecting the dots. Or I'm dumb!

TIA

🌐
DigitalOcean
digitalocean.com › community › tutorials › python-add-to-dictionary
How to Add and Update Python Dictionaries Easily | DigitalOcean
October 16, 2025 - Just like the merge | operator, if a key exists in both dictionaries, then the update |= operator takes the value from the right operand. The following example demonstrates how to create two dictionaries, use the update operator to append the second dictionary to the first dictionary, and then ...
🌐
Codecademy
codecademy.com › docs › python › dictionaries › .update()
Python | Dictionaries | .update() | Codecademy
May 13, 2025 - In Python, the .update() method adds key-value pairs from another dictionary or an iterable of key-value pairs to the target dictionary. If a key already exists, its value is updated; otherwise, a new key-value pair is added.
Find elsewhere
🌐
InterServer
interserver.net › home › python › learn how to modify python dictionary values easily
Learn How to Modify Python Dictionary Values Easily - Interserver Tips
February 3, 2026 - You’ve now learned the main ways to change dictionary items in Python – using direct assignment, the update() method, and dictionary comprehensions.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-update-dictionary-value-by-key
Python Update Dictionary Value by Key - GeeksforGeeks
July 23, 2025 - In this example, I have created a dictionary student_info, and we updated the 'grade' key to the new value 'A' using the square bracket notation. ... # Creating a student information dictionary student_info = {'name': 'Geek', 'age': 21, 'grade': 'B'} # Updating the 'grade' key with value 'A' student_info['grade'] = 'A' # Displaying the updated dictionary print(student_info)
🌐
W3Schools
w3schools.com › python › ref_dictionary_update.asp
Python Dictionary update() Method
MongoDB Get Started MongoDB Create DB MongoDB Collection MongoDB Insert MongoDB Find MongoDB Query MongoDB Sort MongoDB Delete MongoDB Drop Collection MongoDB Update MongoDB Limit ... Python Overview Python Built-in Functions Python String Methods Python List Methods Python Dictionary Methods Python Tuple Methods Python Set Methods Python File Methods Python Keywords Python Exceptions Python Glossary
🌐
Programiz
programiz.com › python-programming › methods › dictionary › update
Python Dictionary update()
The update() method updates the dictionary with the elements from another dictionary object or from an iterable of key/value pairs. marks = {'Physics':67, 'Maths':87} internal_marks = {'Practical':48}
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-update-nested-dictionary
Update Nested Dictionary - Python - GeeksforGeeks
July 12, 2025 - If not, initializes it as an empty dictionary. Second setdefault("email", "bob@example.com"): Within the "contact" dictionary, checks for the key "email". If absent, sets it to "bob@example.com". The defaultdict from Python's collections module automatically initializes nested dictionaries, eliminating the need to check for key existence manually.
🌐
Python documentation
docs.python.org › 3 › tutorial › datastructures.html
5. Data Structures — Python 3.14.6 documentation
You can’t use lists as keys, since lists can be modified in place using index assignments, slice assignments, or methods like append() and extend(). It is best to think of a dictionary as a set of key: value pairs, with the requirement that the keys are unique (within one dictionary).
🌐
Tutorialspoint
tutorialspoint.com › python › dictionary_update.htm
Python dictionary update() Method
The Python dictionary update() method is used to update the key-value pairs of a dictionary. These key-value pairs are updated from another dictionary or iterable like tuple having key-value pairs.
🌐
Python.org
discuss.python.org › python help
Need to modify a value in a dictionary to a float and append dictionary - Python Help - Discussions on Python.org
September 7, 2022 - Hello everyone. I have a value in a dictionary that I need to divide by a float and then append the dictionary to update the value. When I try to do this python says it can’t do this as the number is not a float. Here i…
🌐
DataCamp
datacamp.com › tutorial › python-dictionary-append
Python Dictionary Append: How to Add Key-Value Pairs | DataCamp
August 6, 2024 - The merge operator (|) combines the key-value pairs from both dictionaries, making it a quick and convenient method for merging dictionaries. For in-place updates, Python 3.9 also introduced the update |= operator.
🌐
Note.nkmk.me
note.nkmk.me › home › python
Add and Update an Item in a Dictionary in Python | note.nkmk.me
August 25, 2023 - If the key already exists, it is overwritten with the value specified in the argument. d = {'k1': 1, 'k2': 2} d.update(k1=100, k3=3, k4=4) print(d) # {'k1': 100, 'k2': 2, 'k3': 3, 'k4': 4} ... An error is raised if the same key is specified multiple times. # d.update(k3=3, k3=300) # SyntaxError: keyword argument repeated: k3 ... In this case, keys must be valid identifiers in Python.
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › python dictionary update() method
Python Dictionary update() Method -
May 31, 2024 - Python dictionary update() method is used to update the dictionary using another dictionary or an iterable of key-value pairs(such as a tuple). If the key
🌐
KDnuggets
kdnuggets.com › 2023 › 02 › update-python-dictionary.html
How to Update a Python Dictionary - KDnuggets
February 20, 2023 - Learn how to update a Python dictionary using the built-in dictionary method update(). Update an existing Python dictionary with key-value pairs from another Python dictionary or iterable.
🌐
Quora
quora.com › How-do-I-update-key-and-value-in-dictionary-in-python
How to update key and value in dictionary in python - Quora
EDIT: This is called “inverting” a dictionary. You can do it by iterating through the dict, using .items() to extract each key/value pair and making the value the key, and vice versa: >>> name_to_num = { 'Bruce Lee': 36564, 'Bob Ross': 37381, 'Mary Barra': 98927 } ... You may recognize the pattern above, namely–creating an empty container and then filling it via a loop, as being the exact situation in which one should use a comprehension in Python.
🌐
UiPath Community
forum.uipath.com › help
Update Dictionary Value if Key exists - Help - UiPath Community Forum
February 25, 2019 - So I have this Dictionary<Uielement, Double>. I’m looping through a bunch of rows, and adding things to this dictionary like the label of the product And the price . Sometimes I’ll have more than one row of the same pro…