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

green is not defined

don't quite get the problem but the error message says green is not defined

colors = [green, red, blue, black, white]
Hasan Ahmad
Hasan Ahmad
6,727 Points

In your code, the list of colours are being interpreted as variables by python, hence you get an error saying that green is not defined. However, if you add quotes around each colour in the list, the colours will be strings. For example:

animals = ["Panda", "Bear", "Rabbit", "Pigeon"]

Always remember these data types and how they are created: ** Strings **:

  • You create strings in python with quotation marks around them; it can be single quotes or double quotes
  • ex.) "Panda"

** Integer **

  • Integer's in all languages are ** WHOLE ** numbers

** Float **

  • Floats in all languages are ** NOT WHOLE NUMBERS **
  • ex.) 2.3

I hope this helps!

1 Answer

Todd Anderson
Todd Anderson
4,260 Points


None of those are defined because the list is expecting strings but you have forgotten the "" around each color.