Skip to content
Advertisement

TypeError when adding variable [closed]

I took working example code and tried to add another variable self.species = martian under the init method. Seems you cannot do this which doesn’t make sense to me.

JavaScript
JavaScript

Advertisement

Answer

this is how your code should look like.

JavaScript

I suggest you watch some other beginner’s video lectures on ‘init’ method and ‘Object oriented programming in python’ before writing these type of codes otherwise it would be very hard to understand beyond this point

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement