if 'hallo' in ['hallooo','halloooooooo'] problem

Robert rmanx at gmx.de
Thu Apr 8 09:30:14 EDT 2004


Hi,

I have a little problem and mybe one of you has got the solution.
I would like to check if a string is in a list of strings.
The following returns true:
if 'hallo' in ['halloooo','hallooooooooo']:
    pass

but I want to check if the string is exactly equal to any string in the
list.
How can I do this without the need to do something like this:
def stringInList(self,string,list):
        for oneStr in list:
            if string == oneStr:
                return 1
        return 0


Thank you in advance,

Robert





More information about the Python-list mailing list