Python Modifying Values - Web Development and Design | Tutorial for Java, PHP, HTML, Javascript Python Modifying Values - Web Development and Design | Tutorial for Java, PHP, HTML, Javascript

Breaking

Post Top Ad

Post Top Ad

Thursday, December 6, 2018

Python Modifying Values

Python Modifying Values



Modifying values

You can modify the value associated with any key in a dictionary. To do so give the name of the dictionary and enclose the key in sqaure brackets, then provide the new value for that key.

#Modifying values in a dictionary
alien_0 = {'color': 'green', 'points':5}
print(alien_0)

#change the aliein's color and point value.
alien_0['color'] = 'yellow'
alien_0['points'] = 10
print(alien_0)

Screenshot 

 

No comments:

Post a Comment

Post Top Ad