[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
    else:
        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?

Thanks,

Britt

--
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