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) Hack-n-Slash Game Planning

Onur Salman
Onur Salman
3,612 Points

The workspace code loads with bunch of red highlighted code

While using the workspace , when I tried to create jubjub = Goblin() for practice (after from monster import Monster, which gave no error message) it says Goblin is not defined is it because code loads with red highlights in it ? I didn't touch the code at all I started the workspace in Game Planning video as instructed and tried jubjub = Goblin(). What am I doing wrong ? Also how do I get rid off the red highlighted code ?

Thanks for the help everybody.

Chris Freeman
Chris Freeman
Treehouse Moderator 68,423 Points

Please create a snapshot and post the link. You can create a snapshot of your workspace using the camera icon in the upper right of your workspace.

3 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,423 Points

Hi Onur, when importing modules or module objects, all must be explicitly declared.

Goblin is within the monster module. It can be imported and referenced in two ways:

# direct import and reference
from monster import Goblin

jubjub = Goblin()


# Or, through the module
import monster

jubjub = monster.Goblin()

Post back if you need more help.

I found the red highlighting was due to the tab-in size changing. I was using 4 spaced tabs and in the new Workspaces it had changed to 2. Either you can change the spaces in the bottom left by clicking on the number after 'Spaces ' or you can manually change the tab-ins to match what python is expecting.

Onur Salman
Onur Salman
3,612 Points

Thank you Chris , I forgot to do the from monster import Goblin.