I find myself many times, I write the same piece of code:
def stringInList(str, list): retVal = False for item in list: if str in item: retVal = True return retVal
Is there a way to write this function faster / with less code? I usually use this in an if statement, for example:
if stringInList(str, list): print 'string was found!'
python string list
fredrik Nov 01 '13 at 12:49
source share