Last active
November 9, 2017 08:28
-
-
Save ishankhare07/af5576d844bd13d8a0487b9a7815ceb4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = {} | |
# add a key-value pair | |
a['name'] = 'ishan' | |
# lets see whats in there | |
print(a) | |
# {'name': 'ishan'} | |
# add more key-value pairs | |
a['age'] = 23 | |
a['gender'] = 'male' | |
print(a) | |
# {'gender': 'male', 'age': 23, 'name': 'ishan'} | |
# note above that the keys are not in the same order as we entered them, | |
# this is because python's dictionaries are unordered | |
# see https://stackoverflow.com/a/15479974/2972348 | |
# get a specific value | |
print(a['name']) | |
# 'ishan' | |
# let's update a value | |
a['age'] = 24 | |
print(a) | |
# {'gender': 'male', 'age': 24, 'name': 'ishan'} | |
# let's delete some values | |
del a['age'] | |
print(a) | |
# {'gender': 'male', 'name': 'ishan'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment