Pattern matching with string and list

BartlebyScrivener rpdooling at gmail.com
Tue Dec 13 19:16:20 CET 2005


Even without the marker, can't you do:

sentence = "the fabric is red"
colors = ["red", "white", "blue"]

for color in colors:
    if (sentence.find(color) > 0):
        print color, sentence.find(color)




More information about the Python-list mailing list