However you cannot have identical keys within a dictionary. Attempting to create a second identical key will simply overwrite the first as shown below.
>>> my_dict = { 'key': x for x in range(10) }
>>> my_dict
{'key': 9}
>>>
Special reminder that 6 is not the same as '6' as one is numeric and the other a string, so if these were each a key they would be unique from each other.
So does a dictionary have say separate indexes for keys and if possible separate indexes for values?? Can we think of a dictionary being a data structure which is indexed like LISTS or STRINGS or TUPLES ???
Because you cannot have duplicate keys in a dictionary. It does iterate from 0 to 9, but each time it overwrites the previous value for the key named 'key'. Since 9 is the last value written, it is the only value assigned to 'key'.
This would produce a dictionary with 10 keys:
>>> dict = {f'key{x}' : x for x in range(10)}
>>> dict
{'key0': 0, 'key1': 1, 'key2': 2, 'key3': 3, 'key4': 4, 'key5': 5, 'key6': 6, 'key7': 7, 'key8': 8, 'key9': 9}
Square brackets, rather than list brackets, would be a better term for []. [] is not used solely for lists, but is also used to retrieve the value at a certain index or key of an iterable object (like a list, dictionary, tuple, etc.).
Whenever we want to get the value at a certain index or key of any iterable object (not only lists), we use square brackets like so.