Lowest price ever! Learn Generative AI for 48% less!
Get my discount+ 3
There are no indexes in a dictionary, just keys.
So squares[ key ] == value
( If you put something in the [] that is not in dictionary like
squares [ "anything" ]
It will give a "key" error not "index" out of bound )
+ 2
squares is a dictionary. Where the value to the left of the colon : is the key to access the items value to the right of the colon.
squares[8] = 64
and
squares[3] = 9
Will change the value to the right of the colon if the item with the given key exists, or it will append the item to the dictionary if it does not. The value in the brackets [ ] is the key and the value to the right of = is that items value.
0
K