Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,158 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 67,987 Points

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

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