Python Python Basics (2015) Python Data Types List Creation

James McIntyre
James McIntyre
4,892 Points

green is not defined

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

lists.py
colors = [green, red, blue, black, white]
Hasan Ahmad
Hasan Ahmad
6,723 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,259 Points

Hi!

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