Hi, I am trying to write a snippet of code that checks if the user entered a valid color from an imported file called graphics.py.

# Get a valid color value from the user.
    color = raw_input("Enter a color: ")

graphics.py contains a huge list of built in color names such as:

DarkOrchid4
DarkRed
DarkSalmon
DarkSeaGreen
DarkSeaGreen

How do I have it so my code checks that the user entered something that is within that huge list of colors?

Thanks

theySaid = raw_input("Please enter a, b, or c: ")
if theySaid not in ["a", "b", "c"]:
    print "You didn't follow my instructions. Sad Panda..."

That would take forever considering there are over 150 colors

I am not sure which version of graphics.py you are using. The version I have (Version 4.0 08/2009) does not show any colors, it simply uses the color names supplied by Tkinter.

You draw an object like a circle and fill it with the color selected inside a try/except. It will fail if it is not a valid color. I think Tkinter uses an r,g,b tuple so your program should accept that as well as a name.