what's wrong with my code - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: what's wrong with my code (/thread-22191.html) |
what's wrong with my code - Oaklizard2047 - Nov-03-2019 So i was reading the Python Tutorial and decided to follow one of it's code : class Cat: def __init__(self, name): self.name = name self.tricks = [] def add_trick(self, trick): self.tricks.append(trick)then i put this in the console : a = Cat('Kelly') a.add_trick('sit') but this is what i got: can anyone tell why did this happen? If there's a mistake in the code, please tell the solution
RE: what's wrong with my code - Evil_Patrick - Nov-03-2019 This working Fine for me class Cat: def __init__(self, name): self.name = name self.tricks = [] def add_trick(self, trick): self.tricks.append(trick) a = Cat('Kelly') a.add_trick('sit') print(a.name) print(a.tricks)
RE: what's wrong with my code - Oaklizard2047 - Nov-03-2019 i forgot a line in the error message:
RE: what's wrong with my code - Evil_Patrick - Nov-03-2019 (Nov-03-2019, 05:37 AM)Oaklizard2047 Wrote: i forgot a line in the error message: Can you Post a Screenshot of code window and output? RE: what's wrong with my code - Oaklizard2047 - Nov-03-2019 (Nov-03-2019, 05:45 AM)Evil_Patrick Wrote:for some reason it Works now. I guess it's just a bug... Thanks for your help though(Nov-03-2019, 05:37 AM)Oaklizard2047 Wrote: i forgot a line in the error message:Can you Post a Screenshot of code window and output? |