+ 3
Whats wrong with this
I am trying to use magic Methods for first time, plz bare with me. I don't want to go further lessons without making this one work. I think it's some silly mistake, I googled it but nothing https://code.sololearn.com/cmtB2CPKSK4n/?ref=app
7 Antworten
+ 10
A couple of things:
1. the magic method is __add__ and you have to define it within the class
2. Also, it has to match the npc attributes and has to stay consistent
3. If you want to make the .group parameter optional, use asterisk
Check out how I changed it:
https://code.sololearn.com/cluUW7ojH2G6/?ref=app
+ 4
Dhairyashil Deshpande Yes, because the class declaration as you wrote it makes the npc class inherit (being derived) from str. And that may not neccesarily be compatible in this case.
Also, probably not what you wanted in the first place :)
+ 1
ok I saw your modification,,, thank you very much for clearing that up,,,,, your are great,, thank you
0
it gives error decoding str not supported
0
what changes do you suggest If I want an output of
"general general"
"british scottish"
0
I want to add, class attributes by using magic methods
0
Thank you for your help