I am learning python and doing an exercise about classes. It tells me to add nd attribute to my class and a method to my class. I always thought these were the same thing un
A method is a function defined in the class. An attribute is an instance variable defined in the class.
Example:
class Example(object): def __init__(self, name): self.name = name def hello(self): print 'Hi, I am ' + self.name
Here hello is a method, and name is an attribute.
hello
name