Checking for keywords in several lists
heiko.wolf at dlr.de
Thu Jan 24 11:48:06 CET 2002
imagine some lists of strings like
list1_words = ('word1','word2')
list2_words = ('word3','word4')
Now I want to check if string is whether in list1_words or in
list2_words. I can do that by
if string in list1_words:
elif string in list2_words:
do something else
But if these lists get more, it is very uncomfortable doing it the
Any other suggestions?
I thought of something like
list1_words = ('word1','word2','function1')
list2_words = ('word3','word4','function2')
if string in *_words
to execute the funtion that is given in that list.
I know that it doesn't work exactly that way, but perhaps someone
knows something that leads to such a function...
More information about the Python-list