I keep getting the same error
Here is my code:
class superhero: # setting up hero attributes def_init_(self): self.name = name self.strengthpts = strengthpts self.alterego = alterego self.powers = powers self. motto = motto self.villain = villain # describing hero details def addstrengthpts(self, strengthpts): self.strengthpts = self.strengthpts + points def addname(self, name): if(self.name == "Dr.Cyber"): print("Dr.Cyber") else: print("Mr. Cyber") def addalterego(self, alterego): if(self.alterego == "John Evergreen"): print("John Evergreen") def addpowers(self, powers): if(self.powers == " can fly at fast speeds. He is super strong. he can rewrite the genetiv code of any object. He can controll electronics. He can lift objects with his mind."): print("can fly at fast speeds. He is super strong. he can rewrite the genetiv code of any object. He can controll electronics. He can lift objects with his mind.") else: print("can fly at super fast speeds. he can rewrite the genetic code of any object. He can lift objects with his mind.") def addmotto(self, motto): if(self.motto == "error terminated!"): print(self.motto) def addvillain(self, villain): if(self.villain == "The Glitch"): print(self.villain) else: print("The Bug") def main(): # sets up story newhero = superhero # tells story print("My superhero's name is " + newhero.name + ".") print(newhero.name + "'s alter ego is " + newhero.alterego) print(newhero.name + newhero.powers) print(newhero.name + "'s arch nemisis is " + newhero.villain + ".") print("When " + newhero.name + " fights " + newhero.villain + ", he lets out his famous motto, " + motto) print(newhero.name + " defeated " + newhero.villain + ". Hooray!!!") print(newhero.name + " gains 100 strengthpts.") main()
Please help me fix this code. I have agonizingly tried fixing this code for days and have ran out of ideas to make this python code work. if you have the solution, please insert the whole FIXED code in answers section. if you are going to answer, please write out the correct version of my code, or the way it should be, don't give advice on a single line of code. it would be easiest if you wrote everything down on notepad++, save it, and send that save to me.
https://stackoverflow.com/questions/67442333/i-cannot-get-this-classes-code-to-work-i-keep-getting-the-same-error-please-fi May 08, 2021 at 06:26AM
没有评论:
发表评论