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 trialOnur Salman
3,612 PointsThe 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.
3 Answers
Chris Freeman
Treehouse Moderator 68,454 PointsHi 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.
Jon Hayward
6,203 PointsI 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
3,612 PointsThank you Chris , I forgot to do the from monster import Goblin.
Chris Freeman
Treehouse Moderator 68,454 PointsChris Freeman
Treehouse Moderator 68,454 PointsPlease 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.