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
11,245 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,710 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']