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

What's wrong with my lists in Python basics challenge to make a list of colors?

So this is how I just learned to make a list in Python basics: my_list = [1,2,3]. Can anyone tell me what I'm doing wrong by applying the same format to this challenge?

lists.py
colors = [yellow,black,purple,red,orange] 

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey Melissa,

You're close. You are just missing the quotation marks around each of the colors. Without the "" Python thinks that each of your colors are variables. That's why you will be getting the "... is undefined" error.

colors = ["yellow", "black", "purple", "red", "orange"]

Keep Coding! :)

Thank you, I thought I was making a variable, but I guess the list is not considered part of the variable, or it is what defines the variable? During the previous video the example given in workspace on how to create a list using Python was done this way: my_list = [1,2,3] etc. and no "" were used, do you know why it would be different, is it because we were using numbers?

Jason Anders
Jason Anders
Treehouse Moderator 145,860 Points

In this example, colors is the name of the variable, which is storing a list of colors (values). So, yes, you are making a variable, but there are different parts.

With numbers, you don't use quotes unless you specifically want them to be a string. With no quotes they remain as numbers. You'll also not use "" around Boolean values (True or False).

If your still struggling a bit with this, I would suggest going back and reviewing the first three videos in this course on naming, numbers and strings, as different types have different methods and can do different things. This will all be very important in the future lessons. Reviewing videos is very common.

Hope this helps some. :)