[Tutor] A Better Way to Write This?
Sat, 17 Feb 2001 17:37:10 -0800
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
if choice == ("black") or choice == ("white") or choice == ("green") or
choice == ("blue"):
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