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?
colors = [yellow,black,purple,red,orange] 

2 Answers

Jason Anders
Jason Anders
Treehouse Moderator 143,830 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 143,830 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. :)