+ 1

Why this aint working

shouldnt this print {"tbk":goblin} https://code.sololearn.com/ci21OK7C70v2/?ref=app

13th Mar 2020, 9:02 AM
Y AD Ù
Y AD Ù - avatar
5 ответов
+ 3
[] instead of () for accessing your dict.
13th Mar 2020, 9:07 AM
HonFu
HonFu - avatar
+ 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}'
13th Mar 2020, 11:10 AM
HonFu
HonFu - avatar
+ 2
It is printing the dict. Just ran your code and saw it.
13th Mar 2020, 9:13 AM
HonFu
HonFu - avatar
0
~ swim ~ i was trying to add the name and the corresponding object as key value pair when and object is instantiated
13th Mar 2020, 9:12 AM
Y AD Ù
Y AD Ù - avatar
0
HonFu now its telling an object is created..,it aint printing the dict..
13th Mar 2020, 9:13 AM
Y AD Ù
Y AD Ù - avatar