Dictionaries
list items are accessed in order by index number. This isn't always the way we want it to work.
Dictionaries are a slightly different type of list that access data by giving each item a key. This creates what we call key:value pairs
Changing an item
Eg:myUser = {"name": "David", "age": 128}
myUser["name"] = "The legendary David"print(myUser)
# This code outputs 'name:'the legendary David', 'age':'128.
Eg:
myUser = {"name": "David", "age": 128}
myUser["name"] = "The legendary David"
print(myUser)
# This code outputs 'name:'the legendary David', 'age':'128.
Comments
Post a Comment