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 trialEuenlee Tan
2,165 PointsHow do I make a list with the variable colours.
How do I do it? I use colors=[Red,Yellow,Blue,Green,Purple] And it said red isn't defined
2 Answers
Nathan Tallack
22,160 PointsYou need to pop your strings (that's what your color names are) inside of "" quotes so that it is recognised as a string. Without them it thinks you are typing variable names or other such things. Consider my example below:
colors = ["Red", "Yellow", "Blue", "Green", "Purple"]
Also, one other thing. Readability is VERY important in Python. When someone else is reading your code, or even when you are reading it at a later time, you will appreciate the spaces following the comma and surrounding the assignment operator (the = sign). While not strictly required, good habit to develop early. ;)
Chris Freeman
Treehouse Moderator 68,441 PointsYou are close. You need to put the words in quotes:
colors = ['Red', 'Yellow', 'Blue', 'Green', 'Purple']
Euenlee Tan
2,165 PointsEuenlee Tan
2,165 PointsWhat's the=sign?