[Tutor] A Better Way to Write This?

Britt Green britt_green@hotmail.com
Sat, 17 Feb 2001 17:37:10 -0800

Hello all,

I have a tiny program that asks a user to enter a color choice. There are 
four valid choices for the user to enter. I have a function that checks to 
see if the user entered one of the valid choices. A snippet from it looks 
like this:

    if choice == ("black") or choice == ("white") or choice == ("green") or 
choice == ("blue"):
        return 1
        return 0

While this works, it seems ugly. What would happen, for example, if there 
were ten or twenty correct colors?

So I'm wondering if there is a better way to write this?



It is pitch black. You are likely to be eaten by a grue.

Get your FREE download of MSN Explorer at http://explorer.msn.com