I\'d like to find the index of the first occurrence of any “special” character in a string, like so:
>>> \"Hello world!\".index([\' \', \'!\']) 5 >
Not as optimized as Padraic Cunningham's solution, but still a one liner:
string = "Hello world!" specials = [' ', '!', 'x'] min(map(lambda x: (string.index(x) if (x in string) else len(string)), specials))