Pattern matching with string and list

BartlebyScrivener rpdooling at gmail.com
Tue Dec 13 13:16:20 EST 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