Hi everyone,

I'm trying to write some code for this question. I believe I have the right answer but it says it isn't.

Anyways here is the question.

1) Given that dict1 refers to a dictionary, change the value mapped to by the key 'Boo' to 'Hoo' .

My code is:

dict1['Hoo'] = dict1['Boo']

Thanks in advance

No,that doesn't quite work. What you would be doing is assigning the key 'Boo' to have the same value as they key 'Hoo'. The question wants you to change the value of dict1 to 'Hoo'

>>> mydict = { 'bar':'none', 'Boo':'something' }
>>> print mydict['Boo']
something
>>> mydict['Boo'] = 'Hoo'
>>> print mydict
{'bar': 'none', 'Boo': 'Hoo'}
>>> print mydict['Boo']
Hoo

Oh it was actually a lot simplier than I expected haha... Dang I misread it a lot :/

Thanks

No,that doesn't quite work. What you would be doing is assigning the key 'Boo' to have the same value as they key 'Hoo'. The question wants you to change the value of dict1 to 'Hoo'

>>> mydict = { 'bar':'none', 'Boo':'something' }
>>> print mydict['Boo']
something
>>> mydict['Boo'] = 'Hoo'
>>> print mydict
{'bar': 'none', 'Boo': 'Hoo'}
>>> print mydict['Boo']
Hoo