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 Python Basics (2015) Python Data Types List Creation

Euenlee Tan
Euenlee Tan
2,165 Points

How 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
Nathan Tallack
22,159 Points

You 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. ;)

Euenlee Tan
Euenlee Tan
2,165 Points

What's the=sign?

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,423 Points

You are close. You need to put the words in quotes:

colors = ['Red', 'Yellow', 'Blue', 'Green', 'Purple']