Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Object-Oriented Python (retired) Objects Class Methods

As others have mentioned, something is wrong with the Workspace, or the code....

Using the code provided in the Workspace (and even rewriting it on my own), I keep getting the same error:

<code>

from monster import Monster
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/treehouse/workspace/monster.py", line 5
sound = 'roar'
^
TabError: inconsistent use of tabs and spaces in indentation </code>

The above results from: <code>

class Monster: hit_points =1 color = 'yellow' weapon = 'sword' sound = 'roar'

def battlecry(self):
    return.self.sound.upper()

</code>

1 Answer

Paul Bentham
Paul Bentham
24,090 Points

Make sure that you are consistent in your spacing, it will throw errors occasionally if you mix between using 4 spaces or tabs.

See here: https://www.python.org/dev/peps/pep-0008/#tabs-or-spaces