Computer Science, asked by darpanu3990, 1 year ago

Implement the class myDict with the methods below, wch will represent a dictionary without using a dictionary object. The methods you implement below should have the same behavior as a dict object, including raising appropriate exceptions. Your code does not have to be efficient. Any code that uses a Python dictionary object will receive 0.

Answers

Answered by san2018
3
>>> foo = {'one key': 'one value', 'second key': 'second value'} >>> "In the middle of a string: {foo.keys()}".format(**locals())
Answered by RitaNarine
0

Any code that uses a Python dictionary object will receive 0;

class CustomDictOne(dict):

  def __init__(self):

     self._mydict = {}

class CustomDictTwo(dict):

  def __init__(self):

     class myDict(dict):

   def __init__(self):

       self._dict = {}

       def add(self, id, val):

       self._dict[id] = val

md = myDict()

md.add('id', 123)

print md[0]

#SPJ2

 

Similar questions