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 trialMark Ilori
Courses Plus Student 161 Pointschallenge machine bugged?!?
NameError: name 'blue' is not defined on my code
but im pretty sure you cant get much wrong with this simple code i have here
colours_list = [blue, orange, red, violet, indigo]
1 Answer
Johannes Scribante
19,175 PointsHi Mark,
When creating a list you can put anything inside the list. That includes variable, strings, numbers, and other lists.
Python has a way or recognizing each of these types.
variable
: this is a variable
"string"
: this is a string
2
: this is a number
[variable, 3, "string"]
: this is a list
You have essentially made a list of variables, so when python is asked to include the variable blue it looks through the script for a variable blue and because it cannot find the variable, python throws an error. Try making you list entries strings.
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherIn addition to Johannes Scribante 's excellent answer, I would point out that the challenge is also looking for the list to be named
colors
. When doing these challenges and it asks for a specific variable name you must use that variable name, otherwise, the checker will be unable to determine the value of the variable it is looking for. It's also important to note that the spelling must be exactly as they have it. If I erased the_list
from your variable name, it would still be incorrect as you are using the British English spelling ofcolours
instead of the American English spelling ofcolors
.