Answers for "can we put the object as value in a dictionary in python*"

0

can we put the object as value in a dictionary in python*

class MyObject():
    def getName(self):
       return self.name

    def getValue(self):
       return self.value

    def __init__(self,name, value):
       self.name = name
       self.value = value


dict = {}
object = MyObject('foo', 2) //foo is the name, 2 is the value
dict[object.getName()] = object
Posted by: Guest on March-24-2022

Code answers related to "can we put the object as value in a dictionary in python*"

Python Answers by Framework

Browse Popular Code Answers by Language