python dictionary change value code example
Example 1: change dictionary value python
my_dict = {
'foo': 42,
'bar': 12.5
}
my_dict['foo'] = "Hello"
print(my_dict['foo'])
#This will give the output:
'Hello'
Example 2: how to change key to value and versa in python dictionary
dict = {value:key for key, value in dict.items()}
Example 3: updating a value in dictionary python
dictionary["key"] = newvalue