0
Are the location of arguments different?
It the example we have: squares [3]= 9 Then in the result, we have: {1:1, 2:4, 3:9,...} Does this mean that when dealing with dictionaries, bytes start counting from 1 and not 0? In other words, for a list: [ "a", "b", "c", "d"] location of a is 0 location of b is 1 and so on...
2 Respostas
+ 2
Not exactly, in the dictionaries you put the value of the index, it is not an obligation that starts is 1. As for the lists, the index of each element is placed automatically and always indicates from 0
+ 1
In dictionaries, the value is accessed through a key. In your case, in the dictionary
1 is the key for 1
So squares[1] will give 1
2 is the key for 4
So squares[2] will give 4
3 is the key for 9
So squares[3] will give 4
If the dictionary was
cubes ={1:1, 2:8, 3:27}
So cubes[3] would give 27.
Even if the keys were not in order it would be the same
cubes = {3:27, 1:1, 2:8}
cubes[3] would still give 27