At 11:40 PM 2/15/2005, Alan Gauld wrote:
Is there a better way for raw_input to accept both caps and lower
case letters than:
def aFunction():
action = raw_input("Perform an action?(y,n): ")
action = raw_input("Perform an action?(y,n): ").upper()
if action == 'y' or action == 'Y':
> Is there a better way for raw_input to accept both caps and lower
case
> letters than:
>
> def aFunction():
>action = raw_input("Perform an action?(y,n): ")
>if action == 'y' or action == 'Y':
if action in 'yY':
>anotherFunction()
>elif action == 'n' or action == 'N':
On Wed, 16 Feb 2005, Tony Meyer wrote:
> >> Is there a better way for raw_input to accept both caps and
> >> lower case letters than:
> [...]
> >>if action == 'y' or action == 'Y':
> >
> > if action in 'yY':
> > dostuff()
> [...]
> > Although, that does mean that if a user enters 'nN' they'l
>> Is there a better way for raw_input to accept both caps and
>> lower case letters than:
[...]
>>if action == 'y' or action == 'Y':
>
> if action in 'yY':
> dostuff()
[...]
> Although, that does mean that if a user enters 'nN' they'll
> get no, but that shouldn't be a huge problem, and it i
if action in 'yY':
dostuff()
elif action in 'nN':
doothersutff()
Although, that does mean that if a user enters 'nN' they'll get no,
but that shouldn't be a huge problem, and it it does, you can just do
a if len(action) != 1...
HTH
Liam Clarke
On Tue, 15 Feb 2005 15:16:37 -0800, Luke Jordan