52. Dictionary keys Flashcards
can dictionary put a dictionary key in a dictionary to print, example
‘[100]’ : True
print (dictionary[100])
usually has to be a spirng plus this will not print :(
what does .get
- method on object or method,
- use if you want to look for a the right hand side
what if you use .get, how do you add a default value?
-user.get(‘age’, 55))
in this example the user is the name of the dictionary. get is the mthod, age is the left hand, see if you have tha to see the left side, if not the default is 55
What is another way to do a dictionary?
user 2 = dict(name= ‘JohnJohn’)
print(user2)
prints: {‘name’: ‘JohnJohn’
what does .keys do?
-checks keys, ON THE LEFT side, if it is there
what does .values do?
does over right side and says if it is true.
what does clear do?
empty object :)
what does user. copy do?
copies the first copy, and cfretes two copies, but if you erase the first one, you have the second one
what does .update do when you write
print(user.update([‘ages’: 55]))
- it updates the key value
*