Sorry, missed an option in there: > def get_word(s, which=1, sep=','): > return s.split(sep)[which-1].strip() > > >>> > >>> get_word('bread, butter, milk') > 'milk' > > >>>
>>> get_word('bread, butter, milk') 'bread' >>> get_word('bread, butter, milk', 3) 'milk' >>> get_word('bread is brown, butter is yellow, milk is white') 'bread is brown' >>> get_word('bread is brown, butter is yello, milk is white', 3) 'milk is white' -- http://mail.python.org/mailman/listinfo/python-list