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

I don't understand what the mistake it is in this: (python lists creation)

colors_list = [1, 2, 3, 4, 5] The program says: NameError: 'colors' is undefined.

lists.py
qcolors_list = [1, 2, 3, 4, 5]

I mistakenly added a q before colors there so please ignore it

2 Answers

Ezra Siton
Ezra Siton
12,644 Points

Create var named colors (You wrote "colors_list") + add strings items (not numbers)

Example:

colors = ['blue', "orange", "black", "yellow", 'gray']
Samuel Ferree
Samuel Ferree
31,722 Points

can you post your whole code?

The text in your post defines a list names colors_list and the code you posted defines a list name qcolors_list but the error seems like you used a variable name colors somewhere in your code.

Maybe the challenge is expecting colors, and you have to define it... maybe just take list off your variable name then?

colors = ['red','blue','green']