I input the following:
>>> collection={} #Initiate an empty dictionary
>>>collection={ 'a':'first', 'a':'second','d ':'third','b':' fourth','e':'fi fth','b':'sixth '}
>>> collection
{'a':'second',' b':'sixth','e': 'fifth','d':'th ird'}
Now my question is:
Why does the output not include all the values (2 values for 'a' AND 2 values for 'b) BUT only shows the output of ONLY the second value for both these keys ('a' and 'b') that I have entered ?
Is the reason be that the values of the keys - 'a' and 'b' are rewritten for the second values that I subsequently have entered ?
Would appreciate your thoughts and comments.
Regards,
Sudip Bhattacharya
**email address removed**
>>> collection={} #Initiate an empty dictionary
>>>collection={ 'a':'first', 'a':'second','d ':'third','b':' fourth','e':'fi fth','b':'sixth '}
>>> collection
{'a':'second',' b':'sixth','e': 'fifth','d':'th ird'}
Now my question is:
Why does the output not include all the values (2 values for 'a' AND 2 values for 'b) BUT only shows the output of ONLY the second value for both these keys ('a' and 'b') that I have entered ?
Is the reason be that the values of the keys - 'a' and 'b' are rewritten for the second values that I subsequently have entered ?
Would appreciate your thoughts and comments.
Regards,
Sudip Bhattacharya
**email address removed**
Comment