my_colors=[ red, blue, green, yellow, white ] why is a name error being shown with the first item of this list?
why is this name error being shown?
my_colors=[ red, blue, purple, yellow, white ]
Erik KriegTreehouse Moderator 43,037 Points
Python is interpreting all those colors as variable names, but since those variables are not defined Python is throwing an error. I suspect your intention was for the colors in the list to be
strings (how text is referred to in most programming languages).
To change these from variables to strings all you need to do is wrap them in quotes,
['red', 'blue', etc...]