+ 1
Why this aint working
shouldnt this print {"tbk":goblin} https://code.sololearn.com/ci21OK7C70v2/?ref=app
5 ответов
+ 3
[] instead of () for accessing your dict.
+ 3
What you see in the output is the default representation of your self-defined type.
If you don't like it, you can overwrite it, using the __repr__ magic method.
Try to insert this into your class:
def __repr__(self):
return f'Goblin 👹 {self.name}'
+ 2
It is printing the dict. Just ran your code and saw it.
0
~ swim ~ i was trying to add the name and the corresponding object as key value pair when and object is instantiated
0
HonFu now its telling an object is created..,it aint printing the dict..