Python Python Basics (2015) Python Data Types List Creation

Miranda Shipley Gonzales
Miranda Shipley Gonzales
222 Points

list practice

colors = [blue, yellow, orange, gold, purple] colors = [red, white, blue, gold, yellow]

Both times when answering the challenge question, I received the answer that the first item in my list was not defined. From the lesson I just viewed, this seems an accurate list. What am I missing? Thank you!

lists.py
colors = [blue, yellow, white, gold, orange]

2 Answers

Nelson J
Nelson J
5,421 Points

Hello there,

The reason you are getting item is not defined is because you are passing in the colors as if they were variables. The challenge is asking you to create a list of colors. You need to surround the colors in the list with single or double quotes because you are passing in strings of colors.

If I were to create a list of colors that I like, I would do the following:

my_list = ['Black', 'White', 'Grey', 'Orange']

You can also use double quotes:

my_list = ["Black", "White", "Grey", "Orange"]

Now, for your list to work without quotes, you would have to define each color before using it. As in my example, I would have to define Black, White, Grey and Orange as variables before I can use them in the list without quotes..

I hope that helps and keep it up, you are doing great. Never give up. :)

Antonio De Rose
Antonio De Rose
20,840 Points

you are missing the quotes inside the list.

colors = ['blue', 'yellow', 'white', 'gold', 'orange']