Abruptly goblins help

**Welcome to the Get Help category!**Hello everyone, please I need some help with the Abruptly Goblins off platform project.

Can a dictionary contain more than one key for each key value pair?

This is where you can ask questions about your code. Some important things to remember when posting in this category :slight_smile:

  • Learn how to ask a good question and get a good answer!
  • Remember to include a link to the exercise you need help with!
  • If someone answers your question, please mark their response as a solution :white_check_mark:
  • Once you understand a new concept, come back and try to help someone else!

Interesting question. The opening proviso with dictionary objects is there are no duplicate keys. Can keys point to other keys, and thus reference the same values? We’ll have to check that.

>>> a = {}
>>> a.update({'jk': 'l'})
>>> a
{'jk': 'l'}
>>> a.update({'mn': a['jk']})
>>> a
{'jk': 'l', 'mn': 'l'}

Okay, so that’s legitimate. Note that both keys have the same value, and more importantly the second key references the first key.

Let’s see what happens when we change the value of `jk’:

>>> a['jk'] = 'h'
>>> a
{'jk': 'h', 'mn': 'l'}
>>> a['mn']

Of particular note here is that the reference is not preserved (persistent). So if we’re ever planning on using this logic, we should reconsider. It’s not going to work beyond the initial setting of 'mn'.

Not sure if this answers your question, but it seems like a fun one to elaborate on, if we’ve not hit the mark, yet.

1 Like