[Tutor] While loop problem

Glen Wheeler gew75 at hotmail.com
Wed Jun 9 02:00:22 EDT 2004


  This really depends on the given situation.

  In this case, I'd say use string.lower():

while name.lower == 'kevin':
  # ...

  You could use a list to hold all the possible responses, all in lowercase
and use a similar construct:

valid = ['jim','bob']

while name.lower() in valid:
  # ...

  Is that better?

  Glen

----- Original Message ----- 
From: "K J" <game at gameweave.com>
To: <tutor at python.org>
Sent: Wednesday, June 09, 2004 3:59 PM
Subject: Re: [Tutor] While loop problem


> Well sorta I want it to be able to to look for anthing like
> Kevin or kevin
>
> while name != 'Kevin': #That only checks for Kevin and not kevin
>
> ----- Original Message -----
> From: "Glen Wheeler" <gew75 at hotmail.com>
> To: "K J" <game at gameweave.com>; <tutor at python.org>
> Sent: Wednesday, June 09, 2004 1:44 AM
> Subject: Re: [Tutor] While loop problem
>
>
> >
> >   Hi Kevin,
> >
> >   Something like
> >
> > while response in 'yY':
> >     # do stuff
> >
> >   ?
> >
> >   Glen
> >
> > ----- Original Message -----
> > From: K J
> > To: tutor at python.org
> > Sent: Wednesday, June 09, 2004 3:07 PM
> > Subject: [Tutor] While loop problem
> >
> >
> > I can't seem to figure out how to make a while loop check for more then
> one
> > thing.
> >
> > I want the while loop to check for both y and Y and return them true
while
> > ever thing else is false.
> >
> > Thanks
> >
> > Kevin
> >
> >
> >
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor
> >
> >
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>



More information about the Tutor mailing list