This is driving me crazy. I want the program to print the name "Frank". However, I get an error that says "AttributeError: 'People' object has no attribute 'called'". I've searched online and as far as I can tell I'm doing everything right, but since I'm getting an error obviously I'm not.
I'm using Python 2.
class People(object):
def __init__(self, name):
self.name = name
def called(self):
return self.name
frank = People("Frank")
print frank.called()
What am I doing wrong?
Looks like an indentation problem.

Dots are spaces, arrows are tabs.
Even though tabs may look like they're equivalent to four spaces in your text editor, Python may not interpret them as such. As a result, you should never mix tabs and spaces. Use only one or the other. Preferably spaces.
I see you're using Notepad++. For ease of debugging, you can configure it to display tabs as arrows by going to View -> Show Symbol, and checking "Show White Space and TAB". You can also configure it to insert four spaces instead of a tab character when you press the tab key, via Settings -> Preferences -> Language Menu/Tab Settings -> Replace by space.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With