[newbie]search string in tuples

Cyril Bazin cyril.bazin at gmail.com
Sat Aug 20 10:54:45 EDT 2005


Try the code below. 

#-------------------------------------------------
list=["airplane","car","boat"]
select = None
while select not in list:
select=raw_input("Which vehicle?")
#-------------------------------------------------

Cyril

On 8/20/05, Viper Jack <nomail at nomail.com> wrote:
> 
> Hi all,
> i'm new to python programming so excuseme if the question is very stupid.
> here the problem.
> this code work
> 
> list=["airplane"]
> select=vars
> while select != list[0]:
> select=raw_input("Wich vehicle?")
> 
> but i want check on several object inside the tuple so i'm trying this:
> 
> list=["airplane","car","boat"]
> select=vars
> while select != list[0] or list[1] or list[2]:
> select=raw_input("Wich vehicle?")
> 
> but loops and doesn't want work.
> I have tried with other methods (for) but nothings.
> I haven't find nothing on this topic, so i asked here.
> Thanks in advance.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20050820/585228e1/attachment.html>


More information about the Python-list mailing list