Google News
logo
Python Program to Change the value of a specific item in a dictionary
In the following example of Python program that changes the value of a specific item in a dictionary :
Program :
# create a dictionary
person = {'name': 'John', 'age': 25, 'gender': 'Male'}

# print the original dictionary
print('Original Dictionary:', person)

# change the value of a specific item
person['age'] = 30

# print the updated dictionary
print('Updated Dictionary:', person)
Output :
Original Dictionary: {'name': 'John', 'age': 25, 'gender': 'Male'}
Updated Dictionary: {'name': 'John', 'age': 30, 'gender': 'Male'}